body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f8;
    color: #222;
}

.page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.card {
    width: 100%;
    max-width: 720px;
    background: white;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.app-title {
    margin-top: 0;
    margin-bottom: 18px;
    font-size: 28px;
}

h2 {
    margin-top: 0;
}

label {
    display: block;
    margin-top: 14px;
    margin-bottom: 6px;
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid #cfd6dd;
    border-radius: 10px;
    font-size: 15px;
}

button {
    margin-top: 18px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #111827;
    color: white;
    font-size: 15px;
    cursor: pointer;
}

button.secondary {
    background: #6b7280;
}

.flash {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 14px;
}

.flash.success {
    background: #dcfce7;
    color: #166534;
}

.flash.error {
    background: #fee2e2;
    color: #991b1b;
}

.muted {
    margin-top: 16px;
    color: #555;
}

.muted a {
    color: #1d4ed8;
    text-decoration: none;
}

.top-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.top-actions form {
    flex: 1;
}

.chat-box {
    border: 1px solid #cfd6dd;
    border-radius: 12px;
    background: #fafafa;
    min-height: 350px;
    max-height: 450px;
    overflow-y: auto;
    padding: 14px;
    margin-bottom: 16px;
}

.msg {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.msg.user {
    background: #dbeafe;
}

.msg.assistant {
    background: #e5e7eb;
}

.msg-role {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
    color: #374151;
}

.msg-content {
    line-height: 1.45;
}

.chat-compose {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 10px;
    align-items: start;
}

.chat-compose textarea {
    min-height: 80px;
    resize: vertical;
    margin-top: 0;
}

.chat-compose button {
    margin-top: 0;
}

/* === Gen-Z friendly background + glassy chat === */
body {
    background: linear-gradient(135deg, #f5f7ff, #eef2ff);
}

.chat-card, .container {
    width: 80%;
    max-width: 1200px;
    margin: 40px auto;
}

/* Chat box modern look */
.chat-box {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 16px;
}

/* Slightly nicer message contrast (non-invasive) */
.msg.user .msg-content {
    background: #eef2ff;
    border-radius: 10px;
    padding: 8px 12px;
}

.msg.assistant .msg-content {
    background: #ffffff;
    border-radius: 10px;
    padding: 8px 12px;
}

/* Improved formatting for assistant responses */
.msg-content h1,
.msg-content h2,
.msg-content h3,
.msg-content h4 {
    margin: 0 0 10px 0;
    line-height: 1.3;
}

.msg-content p {
    margin: 0 0 10px 0;
}

.msg-content p:last-child {
    margin-bottom: 0;
}

.msg-content ul,
.msg-content ol {
    margin: 8px 0 10px 22px;
    padding-left: 0;
}

.msg-content li {
    margin-bottom: 6px;
}

.msg-content strong {
    font-weight: 700;
}

.msg-content em {
    font-style: italic;
}

.msg-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 6px;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.95em;
}

.msg-content a {
    color: #1d4ed8;
    text-decoration: underline;
}

/* ChatGPT-style chat layout */
.chat-layout-body {
    background: #f7f7fb;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    background: #111827;
    color: #f9fafb;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 700;
    padding: 6px 8px;
}

.sidebar-btn,
.sidebar-logout {
    width: 100%;
    margin-top: 0;
    background: #1f2937;
    border: 1px solid #374151;
    color: #f9fafb;
    text-align: left;
    padding: 12px 14px;
    border-radius: 12px;
}

.sidebar-btn:hover,
.sidebar-logout:hover {
    background: #2b3545;
}

.sidebar-section {
    margin-top: 18px;
}

.sidebar-label {
    font-size: 12px;
    text-transform: uppercase;
    color: #9ca3af;
    letter-spacing: 0.04em;
    padding: 0 8px 8px;
}

.sidebar-item {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #f3f4f6;
}

.sidebar-item.active {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
    padding-top: 16px;
}

.main-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
}

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid #e5e7eb;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 24px 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chatgpt-box {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
    padding-bottom: 120px;
    margin-bottom: 0;
}

.composer-wrap {
    position: sticky;
    bottom: 0;
    background: #f7f7fb;
    padding: 12px 0 16px;
    z-index: 20;
}

.chatgpt-compose {
    grid-template-columns: 1fr 110px;
    background: #ffffff;
    border: 1px solid #dbe2ea;
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    max-width: 980px;
    margin: 0 auto;
}

.chatgpt-compose textarea {
    border: none;
    outline: none;
    background: transparent;
    min-height: 64px;
    padding: 10px 12px;
}

.chatgpt-compose button {
    align-self: end;
    border-radius: 12px;
}

.status-inline {
    margin-top: 8px;
    font-size: 14px;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        padding: 16px 16px 0;
    }

    .chatgpt-box {
        height: auto;
    }
}

@media (max-width: 768px) {
    .chat-card, .container {
        width: 95%;
    }

    .chat-compose,
    .chatgpt-compose {
        grid-template-columns: 1fr;
    }

    .chatgpt-compose button {
        width: 100%;
    }
}

.sidebar-secondary {
    width: 100%;
    margin-top: 0;
    margin-bottom: 10px;
    background: transparent;
    border: 1px solid #4b5563;
    color: #e5e7eb;
    text-align: left;
    padding: 12px 14px;
    border-radius: 12px;
}

.sidebar-secondary:hover {
    background: #1f2937;
}