:root {
    /* Vibrant Acrylics palette - improved blending */
    --color-bg-primary: #fffdf5;
    /* Warm off-white canvas */
    --color-watercolor-1: rgba(255, 60, 60, 0.5);
    /* Primary Red */
    --color-watercolor-2: rgba(43, 90, 255, 0.45);
    /* Primary Blue */
    --color-watercolor-3: rgba(255, 200, 0, 0.6);
    /* Primary Yellow */

    --color-text-main: #1a1a1a;
    --color-text-muted: #4a4a4a;

    /* Transparent or deeply translucent elements for the UI */
    --color-paper: rgba(255, 255, 255, 0.1);
    /* Almost fully transparent "glass" */
    --color-paper-solid: #fcfbf9;

    --color-accent: #6b8e23;
    --color-accent-hover: #556b2f;

    /* Slightly more pronounced shadows to define the transparent shapes */
    --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.03);
    --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.05);
}

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

body,
html {
    width: 100%;
    height: 100%;
    font-family: 'Lora', serif;
    color: var(--color-text-main);
    overflow: hidden;
    background-color: var(--color-bg-primary);
}

/* Typography utilities */
.font-lora {
    font-family: 'Lora', serif;
}

.font-outfit {
    font-family: 'Outfit', sans-serif;
}

/* Wet-on-wet Watercolor Background Animation */
.watercolor-bg {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 30%, var(--color-watercolor-1) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, var(--color-watercolor-2) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, var(--color-watercolor-3) 0%, transparent 50%);
    filter: blur(60px);
    z-index: -1;
    animation: drift 30s ease-in-out infinite alternate;
}

.watercolor-bg.alternate {
    background: radial-gradient(circle at 60% 20%, var(--color-watercolor-3) 0%, transparent 40%),
        radial-gradient(circle at 20% 70%, var(--color-watercolor-1) 0%, transparent 50%);
    animation: drift 40s ease-in-out infinite alternate-reverse;
    opacity: 0.8;
}

@keyframes drift {
    0% {
        transform: rotate(0deg) scale(1) translate(0, 0);
    }

    50% {
        transform: rotate(5deg) scale(1.05) translate(2%, 2%);
    }

    100% {
        transform: rotate(-5deg) scale(1.1) translate(-2%, -2%);
    }
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* Gebruik dynamic viewport height voor mobiel */
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 10;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.school-logo {
    height: 55px;
    /* Adjust size as needed */
    width: auto;
    object-fit: contain;
    mix-blend-mode: multiply;
    /* Helps the logo blend nicely into the watercolor background */
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 500;
    color: var(--color-text-main);
    letter-spacing: -0.5px;
}

/* Organic Shapes & Glassmorphism */
.organic-box {
    background: var(--color-paper);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    /* Hand-drawn look */
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.glassmorphism {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.organic-btn {
    background-color: transparent;
    border: 1px currentColor solid;
    color: var(--color-text-main);
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.95rem;
    border-radius: 255px 20px 225px 20px/20px 225px 20px 255px;
    transition: all 0.2s ease;
    outline: none;
}

.organic-btn:hover {
    background-color: var(--color-text-main);
    color: var(--color-paper-solid);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.btn-icon {
    padding: 0.2rem 0.6rem;
    font-size: 1.2rem;
    line-height: 1;
}

/* Sidebar styling */
.history-sidebar {
    position: fixed;
    /* Fixed to the viewport */
    top: 0;
    left: -350px;
    /* Fully hidden off-screen */
    width: 320px;
    height: 100vh;
    z-index: 1000;
    /* Ensure it's above everything */
    transition: left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    /* Slightly bouncy spring effect */
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 0 20px 20px 0;
    /* Only curve the right side */
    border-right: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
    /* Shadow pointing right */
}

.history-sidebar.open {
    left: 0;
    /* Slide fully in */
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
    padding-bottom: 1rem;
}

.sidebar-header h2 {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--color-text-main);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
}

.btn-clear {
    color: #cc4444 !important;
    border-color: #cc4444 !important;
    font-size: 0.85rem !important;
}

.btn-clear:hover {
    background-color: #cc4444 !important;
    color: white !important;
}

.history-item {
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px 20px 10px 20px/20px 10px 20px 10px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.6);
    transform: translateX(3px);
    color: var(--color-text-main);
}

.history-item .history-date {
    display: block;
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}

/* Notebook Area */
.notebook-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 1.5rem;
    scroll-behavior: smooth;
}

/* Custom Scrollbar to match theme */
.notebook-area::-webkit-scrollbar {
    width: 6px;
}

.notebook-area::-webkit-scrollbar-track {
    background: transparent;
}

.notebook-area::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 2rem;
}

/* Messages */
.message {
    max-width: 80%;
    line-height: 1.6;
    font-size: 1.1rem;
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    background-color: rgba(255, 255, 255, 0.4);
    /* Much more transparent */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 15px 255px 15px 225px/225px 15px 255px 15px;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.ai-message {
    align-self: flex-start;
    background-color: var(--color-paper);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Sluier-methode Sources */
.sources-container {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sources-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.sources-title {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
}

.source-card {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    text-decoration: none;
    overflow: hidden;
    transition: all 0.2s ease;
}

.source-card:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.source-img {
    height: 60px;
    width: 100%;
    background-size: cover;
    background-position: center;
    background-color: #f0f0f0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.source-info {
    padding: 0.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--color-text-main);
    overflow: hidden;
    height: 2.8rem;
    font-family: 'Outfit', sans-serif;
}

.source-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.source-card.schooltv {
    background: rgba(224, 242, 254, 0.6);
    border-color: rgba(14, 165, 233, 0.15);
}

.source-card.schooltv:hover {
    background: rgba(224, 242, 254, 0.95);
}

.news-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Reflection Box */
.reflection-message {
    align-self: center;
    max-width: 90%;
    background-color: rgba(254, 202, 87, 0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: var(--color-text-main);
    text-align: center;
    font-style: italic;
    padding: 2rem;
    margin: 1rem 0;
    border-radius: 20px 255px 15px 225px/225px 15px 255px 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Input Area */
.input-area {
    padding: 1rem;
    margin-top: auto;
}

#chat-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    resize: none;
    outline: none;
    font-size: 1.1rem;
    color: var(--color-text-main);
    max-height: 150px;
    padding: 0.5rem;
}

#user-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

#send-btn {
    align-self: center;
}


@media (max-width: 768px) {
    .app-container {
        padding: 0.8rem 0.8rem;
        height: 100dvh;
    }

    .app-header {
        margin-bottom: 1rem;
    }

    .app-header h1 {
        font-size: 1.3rem;
    }

    .school-logo {
        height: 35px;
    }

    .message {
        max-width: 95%;
        font-size: 1rem;
        padding: 1rem;
    }

    .sources-grid {
        grid-template-columns: 1fr;
    }

    .input-area {
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.6);
        /* Iets duidelijker op mobiel */
    }

    #user-input {
        font-size: 1rem;
        padding: 0.4rem;
    }

    .header-title-group {
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 1.2rem;
    }

    .school-logo {
        height: 35px;
    }

    .organic-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    .message {
        padding: 1rem;
    }

    .reflection-message {
        padding: 1.2rem;
        font-size: 1rem;
    }
}

/* Password Overlay Styling */
.organic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-color: var(--color-bg-primary);
    background-image: url('Gemini_Generated_Image_hkpq6hhkpq6hhkpq.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.password-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-bg-primary);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s;
}

.password-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.password-card {
    max-width: 400px;
    width: 90%;
    text-align: center;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.password-card h2 {
    font-size: 1.8rem;
    color: var(--color-text-main);
}

.password-card p {
    font-size: 1rem;
    color: var(--color-text-muted);
}

.password-input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#password-input {
    padding: 0.8rem 1rem;
    border-radius: 15px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
    outline: none;
    text-align: center;
    font-size: 1.1rem;
}

#password-input:focus {
    border-color: var(--color-accent);
}

.error-text {
    color: #cc0000;
    font-size: 0.85rem;
    margin-top: -0.5rem;
}

.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* --- 🙋 Meld-knop --- */
.report-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 0.5rem;
    color: var(--color-text-muted);
    opacity: 0.5;
    transition: opacity 0.2s, background 0.2s;
}

.report-btn:hover:not(:disabled) {
    opacity: 1;
    background: rgba(255, 60, 60, 0.08);
    border-color: rgba(255, 60, 60, 0.3);
}

.report-btn:disabled {
    opacity: 0.8;
    cursor: default;
}