* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
}

/* =========================
   TOP BAR
========================= */

.topbar {
    background: white;
    padding: 22px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 {
    margin: 0 0 6px 0;
    font-size: 26px;
    font-weight: 700;
}

.topbar p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

.account-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* =========================
   MAIN CONTAINER
========================= */

.container {
    width: 94%;
    max-width: 1200px;
    margin: 28px auto;
}

section {
    background: white;
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 22px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
}

h2 {
    margin-top: 0;
    color: #111827;
}

/* =========================
   ACCOUNT CARD
========================= */

.welcome-card {
    padding: 18px 22px;
}

.welcome-card h2 {
    margin-bottom: 6px;
    font-size: 18px;
}

.welcome-card p {
    margin: 0;
    color: #4b5563;
}

/* =========================
   DASHBOARD
========================= */

.dashboard {
    display: grid;
    grid-template-columns: 310px 1fr;
    gap: 20px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* =========================
   JOURNAL SIDEBAR
========================= */

.journal-sidebar {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px;
    min-height: 600px;
    max-height: 700px;
    overflow-y: auto;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.sidebar-header h2 {
    font-size: 18px;
    margin: 0;
}

.entry {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 13px;
    margin-top: 10px;
    transition: 0.2s ease;
}

.entry:hover {
    border-color: #c7d2fe;
    background: #f8faff;
    transform: translateY(-1px);
}

.entry h3 {
    margin: 0 0 7px 0;
    font-size: 15px;
    color: #111827;
}

.entry p {
    margin: 5px 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.45;
}

.entry button {
    margin-top: 8px;
    margin-right: 6px;
    padding: 7px 11px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    background: #e5e7eb;
    color: #111827;
}

.entry button:hover {
    opacity: 0.8;
}

.empty-message {
    color: #6b7280;
    font-size: 14px;
    text-align: center;
    padding: 25px 10px;
}

/* =========================
   CHAT PANEL
========================= */

.chat-panel {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 22px;
    min-height: 600px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 15px;
}

.chat-header h2 {
    margin-bottom: 5px;
    font-size: 20px;
}

.chat-header p {
    margin: 0;
    color: #6b7280;
    font-size: 13px;
}

/* =========================
   CHAT BOX
========================= */

.chat-box {
    min-height: 420px;
    max-height: 500px;
    overflow-y: auto;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px;
}

.ai-message,
.user-message {
    max-width: 85%;
    padding: 13px 15px;
    margin-bottom: 12px;
    border-radius: 12px;
    line-height: 1.55;
    word-wrap: break-word;
}

.ai-message {
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    margin-right: auto;
}

.user-message {
    background: #111827;
    color: white;
    margin-left: auto;
    text-align: left;
}

.ai-message strong,
.user-message strong {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
}

.ai-message p,
.user-message p {
    margin: 0;
}

/* =========================
   CHAT INPUT
========================= */

.chat-input-area {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.chat-input-area input {
    flex: 1;
}

input {
    width: 100%;
    padding: 13px 15px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    font-size: 15px;
    outline: none;
    background: white;
    transition: 0.2s ease;
}

input:focus,
textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* =========================
   BUTTONS
========================= */

.primary-button,
.secondary-button {
    border: none;
    padding: 11px 17px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: 0.2s ease;
    white-space: nowrap;
}

.primary-button {
    background: #111827;
    color: white;
}

.primary-button:hover {
    background: #374151;
    transform: translateY(-1px);
}

.secondary-button {
    background: #e5e7eb;
    color: #111827;
}

.secondary-button:hover {
    background: #d1d5db;
    transform: translateY(-1px);
}

button:disabled,
input:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

/* =========================
   STATUS
========================= */

#statusMessage {
    color: #166534;
    margin-top: 12px;
    font-size: 14px;
    min-height: 20px;
}

#journalStatus {
    color: #6b7280;
}

/* =========================
   QUICK JOURNAL
========================= */

.journal-card {
    margin-top: 22px;
}

.journal-card h2 {
    font-size: 19px;
}

textarea {
    width: 100%;
    min-height: 180px;
    padding: 15px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    resize: vertical;
    font-size: 15px;
    font-family: Arial, sans-serif;
    line-height: 1.5;
    outline: none;
    transition: 0.2s ease;
}

.button-row {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

/* =========================
   SCROLLBARS
========================= */

.chat-box::-webkit-scrollbar,
.journal-sidebar::-webkit-scrollbar {
    width: 7px;
}

.chat-box::-webkit-scrollbar-thumb,
.journal-sidebar::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* =========================
   FOOTER
========================= */

footer {
    text-align: center;
    padding: 30px 20px;
    color: #6b7280;
    font-size: 13px;
}

footer p {
    margin: 5px 0;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 850px) {

    .topbar {
        padding: 18px 20px;
        flex-direction: column;
        align-items: flex-start;
    }

    .account-buttons {
        width: 100%;
    }

    .account-buttons button {
        flex: 1;
    }

    .container {
        width: 94%;
        margin: 20px auto;
    }

    .dashboard {
        grid-template-columns: 1fr;
    }

    .journal-sidebar {
        min-height: auto;
        max-height: 350px;
    }

    .chat-panel {
        min-height: auto;
    }

    .chat-box {
        min-height: 350px;
        max-height: 450px;
    }
}

@media (max-width: 550px) {

    .topbar h1 {
        font-size: 22px;
    }

    section {
        padding: 16px;
    }

    .chat-input-area {
        flex-direction: column;
    }

    .chat-input-area button {
        width: 100%;
    }

    .chat-header {
        align-items: flex-start;
    }

    .chat-header button {
        padding: 9px 13px;
    }

    .ai-message,
    .user-message {
        max-width: 95%;
    }

    .button-row {
        flex-direction: column;
    }

    .button-row button {
        width: 100%;
    }
}