@import url('https://fonts.googleapis.com/css2?family=DM+Mono&family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,600&display=swap');

:root {
    --ink: #17251f;
    --muted: #718078;
    --line: #dfe5df;
    --paper: #f7f9f5;
    --sage: #e7efe5;
    --forest: #1d4d3b;
    --warm: #f6f0e8;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: "DM Sans", sans-serif;
    overflow: hidden;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.eyebrow {
    color: #6d8175;
    font: 11px "DM Mono", monospace;
    letter-spacing: .09em;
    margin: 0 0 8px;
}

.muted {
    color: var(--muted);
    line-height: 1.55;
}

.thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 13px;
}

.thinking-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #82a18d;
    animation: thinking-pulse 1.1s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }
.thinking-dots span { margin-left: 4px; }

@keyframes thinking-pulse {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

.login-card { border-radius: var(--radius-lg); }
.login-card input, .primary, .signup, .new-chat, .header-actions button, .profile { border-radius: var(--radius-sm); }
.composer, .memory-note { border-radius: var(--radius-md); }

.voice-button {
    width: 44px;
    height: 44px;
    border: 1px solid #d5e0d5;
    border-radius: 50%;
    background: #edf5ed;
    color: var(--forest);
    font-size: 18px;
    flex-shrink: 0;
}

.voice-button.recording {
    background: #d65b5b;
    color: white;
    border-color: #d65b5b;
}

.setting-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 0;
    cursor: pointer;
}

.setting-toggle small { display: block; margin-top: 4px; color: var(--muted); }
.setting-toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 80% 15%, #dcebd9, transparent 32%), var(--warm);
}

.login-card {
    width: min(100%, 420px);
    padding: 46px;
    background: #fffdf9;
    border: 1px solid #e6dfd3;
    box-shadow: 0 18px 60px #6d66531c;
}

.logo,
.brand-mark {
    display: grid;
    place-items: center;
    background: var(--forest);
    color: white;
    font: 600 20px Fraunces, serif;
}

.logo {
    width: 46px;
    height: 46px;
    margin-bottom: 30px;
}

.login-card h1 {
    font: 600 36px Fraunces, serif;
    margin: 0 0 12px;
}

.login-card form {
    display: grid;
    gap: 9px;
    margin-top: 30px;
}

.login-card label {
    font-size: 13px;
    font-weight: 600;
}

.login-card input {
    width: 100%;
    padding: 13px;
    border: 1px solid #cfd8cf;
    background: #fff;
    outline-color: var(--forest);
}

.primary {
    margin-top: 8px;
    padding: 13px;
    border: 0;
    background: var(--forest);
    color: #fff;
    font-weight: 600;
}

.signup {
    width: 100%;
    margin-top: 12px;
    padding: 11px;
    border: 1px solid #d5ddd5;
    color: #557060;
    background: #f8faf7;
}

.signup:disabled {
    cursor: not-allowed;
    color: #8a9a90;
    background: #eef2ee;
    opacity: .78;
}

.signup-form {
    margin-top: 18px !important;
    padding-top: 18px;
    border-top: 1px solid #e0e6de;
}

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

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 24px 14px 16px;
    background: #1b3229;
    color: #ecf4ec;
    min-height: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px 30px;
    font: 600 23px Fraunces, serif;
}

.brand-mark {
    width: 28px;
    height: 28px;
    font-size: 14px;
    background: #b8d4a8;
    color: #163124;
    border-radius: 9px;
}

.new-chat {
    padding: 12px;
    border: 1px solid #5a7266;
    background: #315645;
    color: #fff;
    text-align: left;
    font-weight: 600;
}

.side-label {
    margin: 30px 10px 10px;
    color: #a7beb1;
    font: 10px "DM Mono", monospace;
    letter-spacing: .08em;
}

.session-list {
    overflow: auto;
    min-height: 0;
}

.session {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #d6e0d7;
    text-align: left;
}

.session.active,
.session:hover {
    background: #365b48;
    color: #fff;
}

.session-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.delete {
    border: 0;
    background: none;
    color: #b7cabd;
    font-size: 18px;
    opacity: 0;
}

.session:hover .delete {
    opacity: 1;
}

.account-menu { position: relative; margin-top: auto; }
.account {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 10px;
    background: transparent;
    color: #ecf4ec;
    text-align: left;
}
.account:hover, .account[aria-expanded="true"] { border-color: #50675b; background: #294839; }

.avatar {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: #b5d6ab;
    color: #193527;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
}

.account-identity { display:grid; min-width:0; gap:2px; }.account-label { color:#a7beb1; font-size:10px; }.account-identity #account-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; font-weight:600; }.account-chevron { margin-left:auto; font-size:17px; transition:transform .18s ease; }.account[aria-expanded="true"] .account-chevron { transform:rotate(180deg); }.account-dropdown { position:absolute; bottom:calc(100% + 10px); left:0; right:0; padding:7px; border:1px solid #dce5dc; border-radius:var(--radius-md); background:#fff; box-shadow:0 12px 30px #10251b40; z-index:5; }.account-dropdown button { width:100%; padding:10px; border:0; border-radius:8px; background:transparent; text-align:left; color:var(--ink); }.account-dropdown button:hover { background:var(--sage); }.account-dropdown #logout { color:#a33e35; }

.conversation {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    height: 100vh;
    background: #fffdf9;
}

.conversation header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 38px 19px;
    border-bottom: 1px solid var(--line);
}

.conversation h2 {
    margin: 0;
    font: 600 23px Fraunces, serif;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions button {
    padding: 8px 11px;
    border: 1px solid var(--line);
    background: #fff;
    color: #4e5f56;
    font-size: 12px;
}

.message-list {
    overflow-y: auto;
    min-height: 0;
    padding: 34px clamp(20px, 7vw, 92px);
}

.empty-state {
    text-align: center;
    max-width: 410px;
    margin: 16vh auto;
    color: var(--muted);
}

.empty-state h2 {
    font: 600 28px Fraunces, serif;
    color: var(--ink);
}

.spark {
    color: #c18236;
    font-size: 31px;
}

.message {
    margin-bottom: 28px;
    max-width: 760px;
}

.message-meta {
    margin-bottom: 7px;
    color: #6a7b70;
    font: 10px "DM Mono", monospace;
    letter-spacing: .07em;
}

.message-content {
    white-space: pre-wrap;
    line-height: 1.65;
}

.message.user {
    margin-left: auto;
}

.message.user .message-content {
    background: #edf4eb;
    padding: 13px 16px;
    border-radius: 18px 18px 6px 18px;
}

.message.assistant .message-content {
    padding: 14px 16px;
    background: #f5f7f3;
    border-radius: 18px 18px 18px 6px;
}

.message-image {
    display: block;
    width: min(280px, 100%);
    max-height: 280px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #d3dfd3;
}

.message-image-set { display:flex; flex-wrap:wrap; gap:8px; }
.message-image-set .message-image { width:min(190px, 100%); }

.image-caption {
    margin-top: 9px;
}

.composer {
    display: flex;
    align-items: end;
    gap: 10px;
    margin: 0 clamp(20px, 6vw, 80px);
    padding: 10px 12px 10px 16px;
    border: 1px solid #cbd6cc;
    background: #fff;
    box-shadow: 0 5px 16px #263c2b0c;
}

.composer textarea {
    flex: 1;
    border: 0;
    resize: none;
    outline: 0;
    min-height: 44px;
    max-height: 168px;
    line-height: 1.5;
    padding: 12px 0;
    background: transparent;
}

.composer-counter {
    margin: 2px clamp(20px, 6vw, 80px) 0;
    font-size: 11px;
    color: #98a49c;
    text-align: right;
}

.composer-counter.near-limit {
    color: #c05b2d;
}

.image-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 clamp(20px, 6vw, 80px) 8px;
    padding: 8px 12px;
    border: 1px solid #d5e0d5;
    border-radius: var(--radius-md);
    background: #f2f7f2;
    box-shadow: 0 5px 16px #263c2b0a;
}

.image-preview-list { display:flex; gap:8px; flex-wrap:wrap; }
.image-preview-item { position:relative; }
.image-preview-item img { width:56px; height:56px; object-fit:cover; border-radius:8px; }
.image-preview-item button { position:absolute; top:-7px; right:-7px; width:20px; height:20px; padding:0; border:1px solid #c9d6c9; border-radius:50%; background:#fff; color:#68766d; font-size:16px; line-height:16px; }

.image-preview img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
}

.image-preview-note {
    flex: 1;
    font-size: 12px;
    color: #5d6b61;
}

.image-preview button {
    border: 0;
    background: transparent;
    color: #98a49c;
    font-size: 20px;
    cursor: pointer;
}

.send {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--forest);
    color: #fff;
    font-size: 19px;
}

.send:disabled {
    background: #aebbb0;
}

.disclaimer {
    margin: 10px 0 18px;
    text-align: center;
    color: #98a49c;
    font-size: 11px;
}

.memory-panel {
    padding: 31px 25px;
    border-left: 1px solid var(--line);
    background: #f5f8f2;
}

.memory-heading h3 {
    margin: 0;
    font: 600 24px Fraunces, serif;
}

.profile-list {
    display: grid;
    gap: 9px;
    margin-top: 25px;
}

.profile {
    padding: 12px;
    background: #fff;
    border: 1px solid #dfe7dd;
}

.profile-key {
    color: #7b8e80;
    font: 10px "DM Mono", monospace;
    text-transform: uppercase;
}

.profile-value {
    margin-top: 5px;
    font-size: 14px;
}

.memory-note {
    display: flex;
    gap: 10px;
    padding: 14px;
    margin-top: 30px;
    background: #e2efdc;
    color: #47654d;
    font-size: 12px;
    line-height: 1.45;
}

.memory-note p {
    margin: 0;
}

.modal { position:fixed; inset:0; display:grid; place-items:center; padding:20px; background:#13271c80; z-index:10; }.modal-card { position:relative; width:min(100%,560px); max-height:80vh; overflow:auto; padding:32px; border-radius:var(--radius-lg); background:#fffdf9; box-shadow:0 20px 60px #10251b4d; }.modal-card h2 { margin:0;font:600 28px Fraunces,serif; }.modal-close { position:absolute; top:15px; right:15px; width:32px; height:32px; border:0; border-radius:50%; background:#edf2eb; font-size:20px; }.modal-card form { display:grid; gap:12px; margin-top:20px; }.modal-card textarea { width:100%; padding:13px; border:1px solid #cfd8cf; border-radius:var(--radius-sm); outline-color:var(--forest); resize:vertical; }
.dialog-card { width:min(100%,420px); }.dialog-form { margin-top:20px !important; }.dialog-form input { width:100%; padding:12px; border:1px solid #cfd8cf; border-radius:var(--radius-sm); outline-color:var(--forest); }.dialog-actions { display:flex; justify-content:flex-end; gap:9px; }.dialog-actions .primary { margin-top:0; }.dialog-secondary { padding:11px 15px; border:1px solid var(--line); border-radius:var(--radius-sm); background:#fff; color:var(--ink); }.toast-container { position:fixed; right:22px; bottom:22px; z-index:30; display:grid; gap:10px; }.toast { max-width:360px; padding:13px 16px; border:1px solid #e7c4c0; border-radius:var(--radius-sm); background:#fff8f7; color:#8f302b; box-shadow:0 10px 30px #10251b26; opacity:0; transform:translateY(8px); transition:opacity .2s ease, transform .2s ease; }.toast.visible { opacity:1; transform:translateY(0); }.toast.success { border-color:#b9d7bb; background:#f2faf1; color:#28623a; }

@media (max-width:950px) {
    .app {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .memory-panel {
        display: none;
    }
}

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

    .sidebar {
        display: none;
    }

    .conversation header {
        padding: 20px;
    }

    .message-list {
        padding: 24px 20px;
    }

    .composer {
        margin: 0 14px;
    }

    .login-card {
        padding: 32px 25px;
    }
}

.admin-menu-link { display:block; padding:10px; border-radius:8px; color:var(--ink); text-decoration:none; font-size:14px; }
.admin-menu-link:hover { background:var(--sage); }
.admin-page { overflow:auto; background:var(--paper); }
.admin-shell { width:min(1100px,100%); margin:auto; padding:48px 24px; }
.admin-header { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:30px; }
.admin-header h1 { margin:0; font:600 38px Fraunces,serif; }
.header-link { color:var(--forest); text-decoration:none; padding:10px 14px; border:1px solid var(--line); border-radius:var(--radius-sm); background:#fff; }
.admin-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.admin-grid .modal-card { width:auto; max-height:none; }
.modal-card label { display:grid; gap:7px; margin-top:14px; font-size:13px; font-weight:600; }
.modal-card label input,.modal-card label textarea { width:100%; padding:12px; border:1px solid #cfd8cf; border-radius:var(--radius-sm); background:#fff; outline-color:var(--forest); }
.document-list { display:grid; gap:10px; margin-top:20px; }
.document-list { max-height:440px; overflow-y:auto; padding-right:5px; }
.document { display:grid; gap:5px; padding:13px; border:1px solid var(--line); border-radius:var(--radius-sm); background:#fff; }
.document span { color:var(--muted); font-size:12px; }
.index-title { display:flex; justify-content:space-between; align-items:center; gap:12px; }.index-title h2 { margin:0; }.clear-knowledge { margin-top:16px; padding:10px 13px; border:1px solid #dfb7b2; border-radius:var(--radius-sm); background:#fff7f6; color:#9a372f; }.vector-card { width:min(100%,780px); }.vector-card canvas { width:100%; max-height:55vh; margin-top:16px; border:1px solid var(--line); border-radius:var(--radius-md); touch-action:none; }
.admin-link { display:inline-block; margin-top:15px; text-decoration:none; }
.upload-report { margin-top:14px; padding:12px; border:1px solid #e7c4c0; border-radius:var(--radius-sm); background:#fff8f7; color:#8f302b; font-size:12px; line-height:1.5; }.upload-report ul { margin:7px 0 0; padding-left:18px; }
.primary.is-loading { display:inline-flex; align-items:center; gap:9px; opacity:.82; cursor:wait; }.primary.is-loading::before { content:""; width:14px; height:14px; border:2px solid #ffffff80; border-top-color:#fff; border-radius:50%; animation:upload-spin .75s linear infinite; } @keyframes upload-spin { to { transform:rotate(360deg); } }
.upload-hint { font-size:12px; margin:4px 0 0; }
@media (max-width:700px) { .admin-grid { grid-template-columns:1fr; }.admin-header { gap:20px; flex-direction:column; } }
