/* ===== Design System (shared with 3M Framework site) ===== */
:root {
    --ink: #1a2332;
    --ink-light: #4a5568;
    --ink-muted: #718096;
    --accent: #3a8f8a;
    --accent-light: #4aaba6;
    --accent-bg: #eaf3f2;
    --accent-border: #c0d9d7;
    --bg: #faf9f7;
    --bg-white: #ffffff;
    --border: #e2e0dc;
    --border-light: #f0eee9;
}

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

body {
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--ink);
    height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 40%, rgba(232,240,239,0.45) 0%, transparent 70%),
        radial-gradient(ellipse 60% 50% at 80% 20%, rgba(210,225,222,0.12) 0%, transparent 60%);
    background-attachment: fixed;
}

/* ===== App Layout ===== */
.app-container {
    display: flex;
    height: 100vh;
}

/* ===== Mobile Header ===== */
.mobile-header {
    display: none;
    height: 48px;
    padding: 0 16px;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
}

.mobile-brand {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.mobile-menu-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--ink-muted);
    padding: 8px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.mobile-menu-btn:hover {
    background-color: var(--border-light);
    color: var(--ink);
}

/* ===== Sidebar — stable 232px, light background ===== */
.sidebar {
    width: 232px;
    height: 100vh;
    background-color: var(--bg-white);
    border-right: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-body {
    height: 100%;
    padding: 20px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
}

/* Brand */
.sidebar-brand {
    margin-bottom: 20px;
}

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

.logo-icon-img {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brand-name {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.brand-sub {
    font-size: 11px;
    color: var(--ink-muted);
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* New Chat Button */
.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg);
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 20px;
}

.new-chat-btn:hover {
    background-color: var(--accent-bg);
    border-color: var(--accent-border);
    color: var(--accent);
}

.new-chat-btn i {
    font-size: 12px;
    color: var(--ink-muted);
}

.new-chat-btn:hover i {
    color: var(--accent);
}

/* Sidebar Sections */
.sidebar-section {
    margin-bottom: 20px;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 4px;
    margin-bottom: 6px;
}

/* Chat History */
.chat-history {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 200px;
    overflow-y: auto;
}

.history-empty {
    font-size: 12px;
    color: var(--ink-muted);
    padding: 8px 4px;
    opacity: 0.6;
}

.history-item {
    padding: 7px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.12s ease;
    text-decoration: none;
    color: var(--ink-light);
    position: relative;
    overflow: hidden;
}

.history-item:hover {
    background-color: var(--border-light);
    color: var(--ink);
}

.history-item.active {
    background-color: var(--accent-bg);
    color: var(--accent);
}

.history-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
}

.history-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}

.history-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.history-time {
    font-size: 11px;
    color: var(--ink-muted);
    line-height: 1.2;
}

.history-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.history-item:hover .history-actions {
    opacity: 1;
}

.action-btn {
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.12s ease;
    color: var(--ink-muted);
}

.action-btn:hover {
    background-color: var(--border);
    color: var(--ink);
}

.delete-btn:hover {
    background-color: #fde8e8;
    color: #dc2626;
}

/* Framework Nav */
.framework-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--ink-light);
    font-size: 13px;
    transition: all 0.12s ease;
    border-left: 2px solid transparent;
}

.nav-item:hover {
    background-color: var(--border-light);
    color: var(--ink);
    border-left-color: var(--accent);
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding-top: 8px;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 10px;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    text-decoration: none;
    color: var(--ink-muted);
    font-size: 12px;
    transition: color 0.12s ease;
}

.footer-link:hover {
    color: var(--accent);
}

.footer-link i {
    font-size: 11px;
    width: 16px;
    text-align: center;
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 100vh;
}

.main-content.chat-mode {
    justify-content: flex-start;
    align-items: center;
}

.main-content.chat-mode .chat-container {
    flex: 1;
    display: block;
    margin: 0 auto;
}

.main-content.chat-mode .input-section {
    background-color: transparent;
    border-top: none;
    padding: 20px;
    margin-top: auto;
}

/* ===== Welcome Section ===== */
.welcome-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 48px;
    max-width: 900px;
    width: 100%;
}

.welcome-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: -32px 0 0 0;
}

.title-icon {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 16px;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 0.1s forwards;
}

.title-text {
    font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    font-size: 42px;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    text-align: center;
    letter-spacing: -0.02em;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 0.25s forwards;
}

.title-tagline {
    font-size: 15px;
    color: var(--ink-muted);
    font-weight: 400;
    line-height: 1.5;
    max-width: 480px;
    letter-spacing: 0.01em;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 0.4s forwards;
}

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


/* ===== Chat Container ===== */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: none;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.messages {
    max-width: 750px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Messages ===== */
.message {
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.avatar-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.message.user .message-avatar {
    background-color: var(--accent-bg);
}

.message.assistant .message-avatar {
    background-color: var(--accent);
    color: white;
    font-size: 16px;
}

.message-content {
    flex: 1;
    line-height: 1.6;
}

/* Markdown */
.message-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: var(--ink);
    font-family: 'Source Serif 4', Georgia, serif;
}

.message-text h1 { font-size: 1.5em; }
.message-text h2 { font-size: 1.3em; }
.message-text h3 { font-size: 1.2em; }
.message-text h4 { font-size: 1.1em; }

.message-text p {
    margin-bottom: 1em;
}

.message-text ul,
.message-text ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.message-text li {
    margin-bottom: 0.3em;
}

.message-text code {
    background-color: var(--border-light);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.88em;
    color: var(--accent);
}

.message-text pre {
    background-color: var(--ink);
    color: #e2e8f0;
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1em;
}

.message-text pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.85em;
}

.message-text blockquote {
    border-left: 3px solid var(--accent);
    margin: 1em 0;
    padding-left: 1em;
    color: var(--ink-muted);
    font-style: italic;
}

.message-text strong,
.message-text b {
    font-weight: 600;
}

.message-text em,
.message-text i {
    font-style: italic;
}

.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1em;
    font-size: 0.92em;
}

.message-text th,
.message-text td {
    border: 1px solid var(--border);
    padding: 0.5em 0.75em;
    text-align: left;
}

.message-text th {
    background-color: var(--bg);
    font-weight: 600;
    color: var(--ink);
}

.message.user .message-text {
    color: var(--ink);
}

.message.assistant .message-text {
    color: var(--ink-light);
}

/* ===== Input Area ===== */
.input-section {
    background-color: transparent;
    padding: 0;
    width: 100%;
    max-width: 900px;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 0.55s forwards;
}

.input-container {
    max-width: 900px;
    margin: 0 auto;
}

.chat-form {
    margin-bottom: 16px;
}

.input-wrapper {
    position: relative;
    background-color: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: 24px;
    padding: 14px 20px;
    display: flex;
    align-items: flex-end;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 54px;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 110, 106, 0.08);
}

.message-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    min-height: 24px;
    max-height: 240px;
    font-family: inherit;
    color: var(--ink);
    font-weight: 400;
}

.message-input::placeholder {
    color: var(--ink-muted);
}

.input-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: 12px;
}

.attach-btn,
.send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 15px;
}

.attach-btn {
    background-color: transparent;
    color: var(--ink-muted);
}

.attach-btn:hover {
    background-color: var(--border-light);
    color: var(--ink);
}

.send-btn {
    background-color: var(--accent);
    color: white;
}

.send-btn:hover {
    background-color: var(--accent-light);
}

.send-btn:disabled {
    background-color: var(--border);
    cursor: not-allowed;
}

/* Feature Buttons */
.feature-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.feature-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background-color: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--ink-light);
    transition: all 0.15s ease;
    backdrop-filter: blur(4px);
}

.feature-btn:hover {
    background-color: var(--accent-bg);
    color: var(--accent);
    border-color: var(--accent-border);
}

.feature-btn i {
    font-size: 12px;
    color: var(--accent);
    opacity: 0.6;
}

.feature-btn:hover i {
    opacity: 1;
}

/* ===== Hidden Settings Panel ===== */
.settings-panel {
    display: none;
}

.model-selector,
.model-btn {
    display: none;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--ink-muted);
}

/* ===== Typing Indicator ===== */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 10px 0;
}

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

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

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

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 150;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        padding-top: 48px;
        box-shadow: none;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    }

    .sidebar.mobile-open .mobile-overlay {
        display: block;
    }

    .main-content {
        padding-top: 60px;
        min-height: calc(100vh - 60px);
    }

    .welcome-section {
        gap: 36px;
    }

    .welcome-title {
        margin: -16px 0 0 0;
        gap: 12px;
    }

    .title-text {
        font-size: 30px;
    }

    .title-icon {
        width: 80px;
        height: 80px;
        border-radius: 12px;
    }

    .title-tagline {
        font-size: 13px;
        max-width: 320px;
    }

    .input-section {
        opacity: 1;
        animation: none;
    }

    .input-container {
        max-width: 100%;
        padding: 0 8px;
    }
}

@media (max-width: 480px) {
    .title-text {
        font-size: 26px;
    }

    .title-tagline {
        font-size: 12px;
    }

    .feature-btn {
        font-size: 12px;
        padding: 6px 12px;
    }

    .feature-btn i {
        display: none;
    }
}
