/* ================================================================
   OLVERRA LEGAL — style.css  PRODUCTION v5.0
   Mobile-first responsive design.
   Every feature visible on desktop is visible on mobile.
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
    --oxblood:        #721c24;
    --oxblood-hover:  #5a161d;
    --oxblood-light:  rgba(114,28,36,0.10);
    --parchment:      #f9fafb;
    --pure-white:     #ffffff;
    --text-primary:   #111827;
    --text-secondary: #6b7280;
    --border-color:   #e5e7eb;
    --serif:          'Georgia', 'Times New Roman', serif;
    --sans:           -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --display:        'Playfair Display', 'Georgia', serif;
    --sidebar-w:      260px;
    --content-max:    860px;
    --content-pad:    40px;
    --nav-h:          60px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--sans);
    background: var(--parchment);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}
.app-shell { display: flex; height: 100vh; }


/* ================================================================
   SIDEBAR
   ================================================================ */

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--oxblood);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.15);
    z-index: 200;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-top { padding: 12px; flex-shrink: 0; }

.new-chat-btn {
    width: 100%;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.20);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-family: var(--sans);
    transition: all 0.2s;
}
.new-chat-btn:hover { background: rgba(255,255,255,0.16); }

/* ── History ─────────────────────────────────────────────────── */
.history-section {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 12px 12px;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.search-wrapper { position: relative; margin-bottom: 10px; }
.search-icon {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%); font-size: 13px; opacity: 0.5;
    pointer-events: none;
}
.search-wrapper input {
    width: 100%;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 8px 10px 8px 32px;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}
.search-wrapper input:focus {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.30);
}
.search-wrapper input::placeholder { color: rgba(255,255,255,0.45); }

/* ── History list ─────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 2px; }

.history-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.30);
    padding: 12px 4px 4px;
    pointer-events: none;
    user-select: none;
}

.history-item {
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
    color: rgba(255,255,255,0.82);
    font-size: 13px;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
}
.history-item:hover  { background: rgba(255,255,255,0.10); color: white; }
.history-item.active { background: rgba(255,255,255,0.16); color: white; }

.history-item-body {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}
.history-mode-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.85;
}
.history-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    line-height: 1.35;
}
.history-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 14px;
}
.history-item-time {
    font-size: 10.5px;
    color: rgba(255,255,255,0.32);
}
.history-action-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.28);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}
.history-action-btn:hover { background: rgba(255,255,255,0.10); color: #ff6b6b; }

.history-empty {
    padding: 28px 12px;
    text-align: center;
}
.history-empty .empty-icon { font-size: 26px; opacity: 0.28; margin-bottom: 8px; }
.history-empty p { color: rgba(255,255,255,0.30); font-size: 12px; line-height: 1.55; }

.history-section::-webkit-scrollbar { width: 4px; }
.history-section::-webkit-scrollbar-track { background: transparent; }
.history-section::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

/* ── Sidebar footer ──────────────────────────────────────────── */
.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.12);
    flex-shrink: 0;
}
.user-profile {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: 8px;
    cursor: pointer; transition: all 0.2s;
}
.user-profile:hover { background: rgba(255,255,255,0.10); }
.user-profile .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 13px; font-weight: 600;
    flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name {
    display: block; color: white; font-size: 13px; font-weight: 500;
    font-family: var(--serif);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu-btn {
    background: transparent; border: none;
    color: rgba(255,255,255,0.55); cursor: pointer;
    padding: 4px; opacity: 0; transition: all 0.2s; flex-shrink: 0;
}
.user-profile:hover .user-menu-btn { opacity: 1; }

.user-menu-dropdown {
    position: fixed; bottom: 68px; left: 12px;
    background: white; border: 1px solid var(--border-color);
    border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 4px; display: none; z-index: 1100;
    min-width: 180px;
}
.user-menu-dropdown.active { display: block; animation: slideUp 0.2s ease; }
.user-menu-dropdown button {
    width: 100%; padding: 10px 14px;
    background: transparent; border: none; border-radius: 6px;
    cursor: pointer; display: flex; align-items: center; gap: 10px;
    color: var(--text-primary); font-size: 14px; font-family: var(--sans);
    transition: all 0.15s; text-align: left;
}
.user-menu-dropdown button:hover { background: var(--parchment); }


/* ================================================================
   MOBILE OVERLAY
   ================================================================ */

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.50);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; animation: fadeIn 0.2s ease; }


/* ================================================================
   TOP NAV
   ================================================================ */

.main-stage {
    flex: 1; display: flex; flex-direction: column;
    background: var(--pure-white); min-width: 0; overflow: hidden;
}

.top-nav {
    height: var(--nav-h);
    background: var(--pure-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 0 var(--border-color), 0 2px 8px rgba(0,0,0,0.03);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    gap: 12px;
}

.sidebar-toggle {
    display: none;
    background: transparent; border: none;
    color: var(--text-primary); cursor: pointer;
    padding: 8px; border-radius: 8px;
    font-size: 20px; line-height: 1;
    transition: background 0.2s;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--parchment); }

.nav-brand {
    display: flex; align-items: center; gap: 10px;
    cursor: default; flex-shrink: 0;
}
.nav-logo-img { height: 34px; width: auto; object-fit: contain; display: block; }
.nav-brand-divider {
    width: 1px; height: 26px;
    background: var(--border-color); flex-shrink: 0;
}
.hourglass-container { width: 26px; height: 26px; flex-shrink: 0; }
.hourglass-icon { width: 100%; height: 100%; }
.nav-wordmark { display: flex; flex-direction: column; gap: 1px; line-height: 1; }
.nav-wordmark-name {
    font-family: var(--display);
    font-size: 15px; font-weight: 700;
    color: var(--oxblood); letter-spacing: -0.01em;
}
.nav-wordmark-tagline {
    font-size: 9px; font-weight: 600;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: #b0b7c3;
}

.nav-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.nav-btn {
    background: transparent; border: none;
    color: var(--text-primary); padding: 8px 12px;
    border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 500; font-family: var(--sans);
    transition: all 0.2s; white-space: nowrap;
}
.nav-btn:hover { background: var(--parchment); }
.nav-btn-primary {
    background: var(--oxblood); border: none;
    color: white; padding: 8px 14px;
    border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 500; font-family: var(--sans);
    transition: all 0.2s; white-space: nowrap;
}
.nav-btn-primary:hover { background: var(--oxblood-hover); transform: translateY(-1px); }


/* ================================================================
   CHAT VIEWPORT
   ================================================================ */

.chat-viewport {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    background: var(--pure-white);
    -webkit-overflow-scrolling: touch;
}
.chat-viewport::-webkit-scrollbar { width: 5px; }
.chat-viewport::-webkit-scrollbar-track { background: transparent; }
.chat-viewport::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.chat-viewport::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

.messages {
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    padding: 32px var(--content-pad) 160px;
}


/* ================================================================
   MESSAGES
   ================================================================ */

.msg {
    margin-bottom: 28px;
    display: flex;
    gap: 12px;
    animation: fadeIn 0.22s ease;
    width: 100%;
}

.user-msg { flex-direction: row-reverse; }
.user-msg .msg-content { align-items: flex-end; }
.ai-msg { flex-direction: row; }

.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 2px;
}
.ai-msg .msg-avatar   { background: var(--oxblood); color: white; }
.ai-msg .msg-avatar svg { width: 17px; height: 17px; }
.user-msg .msg-avatar {
    background: #374151; color: white;
    font-weight: 600; font-size: 13px;
}

.msg-content {
    flex: 1; min-width: 0;
    overflow-wrap: break-word; word-break: break-word;
}
.ai-msg .msg-content {
    border-left: 2px solid rgba(114,28,36,0.10);
    padding-left: 14px;
}

.user-text {
    background: var(--oxblood); color: white;
    padding: 10px 16px;
    border-radius: 18px 18px 4px 18px;
    display: inline-block; max-width: 100%;
    word-break: break-word;
    font-size: 14.5px; line-height: 1.55;
    box-shadow: 0 1px 4px rgba(114,28,36,0.18);
}

.msg-meta {
    font-size: 11px; color: #b0b7c3;
    margin-top: 5px; font-family: var(--sans);
}
.msg-meta--user { text-align: right; }

.msg-mode-badge {
    display: inline-block; color: white;
    font-size: 10px; font-weight: 700;
    padding: 2px 10px; border-radius: 12px;
    letter-spacing: 0.06em; text-transform: uppercase;
    margin-bottom: 10px; font-family: var(--sans);
}

.typing-indicator .msg-content { animation: pulse 1.5s ease-in-out infinite; }


/* ================================================================
   AI BODY
   ================================================================ */

.ai-body {
    font-family: var(--serif);
    font-size: 15px; line-height: 1.88; color: #1a1a1a;
    overflow-wrap: break-word; word-break: break-word;
}
.ai-body p            { margin: 0 0 0.85em; white-space: normal; }
.ai-body p:last-child { margin-bottom: 0; }
.ai-body li           { white-space: normal; }
.ai-body blockquote   { white-space: normal; }

.ai-body pre, .ai-body .draft-pre {
    white-space: pre-wrap; word-break: break-all; overflow-x: auto;
    font-family: 'Courier New', monospace; font-size: 12.5px;
    background: #f9fafb; border: 1px solid var(--border-color);
    border-radius: 6px; padding: 12px 14px; margin: 8px 0;
}

.irac-head {
    display: flex; align-items: center; gap: 10px;
    background: var(--oxblood); color: white;
    font-family: var(--sans); font-size: 10.5px; font-weight: 800;
    letter-spacing: 0.12em; text-transform: uppercase;
    padding: 8px 14px; border-radius: 5px; margin: 22px 0 10px;
    flex-wrap: wrap;
}
.irac-num { opacity: 0.6; font-weight: 400; font-style: italic; text-transform: none; letter-spacing: 0; font-size: 12px; }
.alpha-head {
    display: flex; align-items: baseline; gap: 8px;
    font-size: 14px; font-weight: 700; color: var(--oxblood);
    margin: 18px 0 7px; padding-bottom: 4px;
    border-bottom: 2px solid #fecaca; flex-wrap: wrap;
}
.alpha-num { color: #b91c1c; font-style: italic; font-weight: 400; }
.num-head { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: #374151; margin: 14px 0 5px; }
.num-badge { background: #fee2e2; color: #991b1b; font-size: 11px; font-weight: 700; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

.legal-ul, .legal-ol { margin: 6px 0 10px; padding-left: 20px; }
.legal-ul li, .legal-ol li { margin-bottom: 5px; line-height: 1.7; color: #374151; }
.legal-sub { list-style: none; margin: 4px 0 8px 10px; padding: 0; }
.legal-sub li { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; font-size: 14px; color: #4b5563; }
.sub-lbl { color: #6b7280; font-style: italic; min-width: 26px; flex-shrink: 0; }

.legal-bq {
    margin: 10px 0; padding: 10px 14px;
    background: #fdf5f5; border-left: 3px solid var(--oxblood);
    font-style: italic; color: #3d1a1e;
    font-size: 13.5px; line-height: 1.8; border-radius: 0 5px 5px 0;
}

.ai-body h2.md-head, .ai-body h3.md-head {
    font-family: var(--display); color: var(--oxblood);
    letter-spacing: -0.01em; margin: 18px 0 8px;
}

.limit-lbl {
    display: inline-block; background: #fef3c7; color: #92400e;
    font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
    padding: 1px 6px; border-radius: 3px; margin-right: 5px; vertical-align: middle;
}
.icode { background: #f3f4f6; color: #111; font-family: monospace; font-size: 12px; padding: 1px 5px; border-radius: 3px; border: 1px solid #e5e7eb; }
.src-ref {
    display: inline-flex; align-items: center;
    background: var(--oxblood); color: #fff !important;
    font-size: 11px; font-weight: 700;
    padding: 1px 7px; border-radius: 10px;
    text-decoration: none !important; margin: 0 2px;
    vertical-align: middle; cursor: pointer; transition: background 0.15s;
}
.src-ref:hover { background: var(--oxblood-hover); }


/* ================================================================
   WELCOME SCREEN + MODE SELECTOR
   ================================================================ */

.welcome-screen { padding: 32px 0 0; animation: fadeIn 0.4s ease; }

.welcome-header { text-align: center; margin-bottom: 28px; }
.welcome-icon { width: 52px; height: 52px; margin: 0 auto 14px; }
.welcome-icon svg { width: 100%; height: 100%; }
.welcome-header h2 {
    font-family: var(--display);
    color: var(--oxblood);
    font-size: 26px; font-weight: 700;
    margin-bottom: 5px; letter-spacing: -0.02em;
}
.welcome-header p {
    color: var(--text-secondary); font-size: 14px;
    font-style: italic; font-family: var(--serif);
}

.mode-selector-label {
    text-align: center; font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: #b0b7c3; margin-bottom: 12px;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.mode-card {
    background: var(--pure-white);
    border: 1.5px solid var(--border-color);
    border-radius: 10px; padding: 14px 12px;
    cursor: pointer; text-align: left;
    transition: all 0.18s ease;
    display: flex; flex-direction: column; gap: 8px;
    position: relative; overflow: hidden;
}
.mode-card::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 2.5px;
    background: var(--oxblood);
    transform: scaleX(0); transform-origin: left;
    transition: transform 0.18s ease;
}
.mode-card:hover { border-color: var(--oxblood); box-shadow: 0 4px 14px rgba(114,28,36,0.10); transform: translateY(-2px); }
.mode-card:hover::before   { transform: scaleX(1); }
.mode-card--active         { border-color: var(--oxblood); background: #fdf5f5; }
.mode-card--active::before { transform: scaleX(1); }

.mode-card-icon    { font-size: 20px; line-height: 1; }
.mode-card-title   { font-family: var(--serif); font-size: 12.5px; font-weight: 700; color: #1a1a1a; margin-bottom: 3px; }
.mode-card-desc    { font-size: 10.5px; color: var(--text-secondary); line-height: 1.4; }
.mode-card-bullets { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 3px; }
.mode-card-bullets li { font-size: 10px; color: #7a8393; padding-left: 10px; position: relative; line-height: 1.4; }
.mode-card-bullets li::before { content: '›'; position: absolute; left: 0; color: var(--oxblood); font-weight: 700; }

.mode-indicator { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode-badge {
    background: var(--oxblood); color: white;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.07em; text-transform: uppercase;
    padding: 3px 12px; border-radius: 20px;
}
.mode-exit-btn {
    background: transparent; border: 1px solid var(--border-color);
    color: var(--text-secondary); font-size: 12px;
    padding: 3px 10px; border-radius: 6px;
    cursor: pointer; transition: all 0.2s; font-family: var(--sans);
}
.mode-exit-btn:hover { background: var(--parchment); color: var(--oxblood); border-color: var(--oxblood); }
.input-box-wrapper.mode-active {
    border-color: var(--oxblood);
    box-shadow: 0 0 0 2.5px rgba(114,28,36,0.08);
}


/* ================================================================
   INPUT AREA
   ================================================================ */

.input-anchor {
    position: fixed; bottom: 0;
    left: var(--sidebar-w); right: 0;
    background: linear-gradient(to top, var(--pure-white) 82%, transparent);
    padding: 14px 0 24px;
    z-index: 50;
}

.input-container {
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--content-pad);
}

.attachment-warning {
    display: none;
    background: #fffbeb; border: 1px solid #f59e0b;
    border-radius: 8px; padding: 7px 12px; margin-bottom: 8px;
    gap: 8px; align-items: flex-start;
    animation: slideDown 0.3s ease;
}
.attachment-warning.active { display: flex; }
.attachment-warning-icon   { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.attachment-warning-text   { flex: 1; font-size: 12px; color: #92400e; line-height: 1.5; }
.attachment-warning-text strong { font-weight: 700; color: #78350f; }
.attachment-warning-close {
    background: transparent; border: none;
    color: #b45309; cursor: pointer; font-size: 15px;
    padding: 0 3px; flex-shrink: 0; line-height: 1; opacity: 0.75;
}
.attachment-warning-close:hover { opacity: 1; }

.draft-download-bar {
    background: #fff8f8; border: 1px solid #fecaca;
    border-radius: 10px; padding: 9px 14px; margin-bottom: 8px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    animation: slideDown 0.3s ease;
}
.draft-download-label { font-size: 13px; font-weight: 600; color: var(--oxblood); flex-shrink: 0; }
.draft-dl-btn {
    background: var(--oxblood); color: white; border: none;
    padding: 5px 14px; border-radius: 6px;
    font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--sans);
    transition: all 0.2s;
}
.draft-dl-btn:hover         { background: var(--oxblood-hover); transform: translateY(-1px); }
.draft-dl-btn--pdf          { background: #1e3a5f; }
.draft-dl-btn--pdf:hover    { background: #162d4a; }
.draft-dl-btn--dismiss      { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); margin-left: auto; font-size: 16px; padding: 3px 10px; }
.draft-dl-btn--dismiss:hover { background: var(--parchment); transform: none; }

.file-preview {
    display: none;
    background: var(--oxblood-light); border: 1px solid var(--oxblood);
    border-radius: 10px; padding: 8px 12px; margin-bottom: 8px;
    align-items: center; gap: 10px;
    animation: slideDown 0.3s ease;
}
.file-preview.active { display: flex; }
.file-info { flex: 1; display: flex; align-items: center; gap: 7px; color: var(--oxblood); font-size: 13px; min-width: 0; }
.file-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--text-secondary); flex-shrink: 0; font-size: 12px; }
.remove-file-btn {
    background: transparent; border: none; color: var(--oxblood);
    cursor: pointer; padding: 4px; border-radius: 4px; flex-shrink: 0;
    transition: all 0.2s;
}
.remove-file-btn:hover { background: rgba(114,28,36,0.15); }

.input-box-wrapper {
    background: var(--pure-white); border: 1px solid var(--border-color);
    border-radius: 22px; padding: 8px 10px;
    display: flex; align-items: flex-end; gap: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); transition: all 0.2s;
}
.input-box-wrapper:focus-within {
    border-color: var(--oxblood);
    box-shadow: 0 0 0 3px rgba(114,28,36,0.08);
}

.attachment-btn {
    background: transparent; border: none; cursor: pointer;
    padding: 7px; border-radius: 8px; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.attachment-btn:hover { background: #f3f4f6; }
.plus-icon { font-size: 26px; font-weight: 300; color: #374151; line-height: 1; }

textarea {
    flex: 1; border: none; outline: none; resize: none;
    font-family: var(--sans); font-size: 15px; line-height: 1.5;
    color: var(--text-primary); background: transparent;
    max-height: 180px; padding: 7px 0; min-width: 0;
}
textarea::placeholder { color: var(--text-secondary); }

.send-btn {
    background: #111111; border: none;
    width: 34px; height: 34px; border-radius: 8px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, transform 0.2s; flex-shrink: 0;
}
.send-btn:hover    { filter: brightness(1.3); transform: translateY(-1px); }
.send-btn:disabled { background: var(--border-color); cursor: not-allowed; transform: none; }
.send-btn.cancel   { background: #dc2626; }
.send-btn.cancel:hover { background: #b91c1c; transform: translateY(-1px); }
.arrow-icon { font-size: 18px; color: white; font-weight: bold; line-height: 1; }

.footer-note {
    text-align: center; font-size: 11.5px; color: #b0b7c3;
    margin-top: 8px; font-family: var(--serif); font-style: italic;
}


/* ================================================================
   SOURCE CARDS
   ================================================================ */

.sources-wrap { margin-top: 18px; padding-top: 12px; border-top: 2px solid #f3f4f6; }
.sources-hdr { font-family: var(--sans); font-size: 10.5px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; }
.sources-list { display: flex; flex-direction: column; gap: 8px; }

.src-card { border-radius: 9px; overflow: hidden; border: 1px solid var(--border-color); background: white; transition: box-shadow 0.2s, transform 0.2s; }
.src-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.09); transform: translateY(-1px); }
.src-card.hl    { box-shadow: 0 0 0 3px #fbbf24, 0 3px 12px rgba(0,0,0,0.10); }

.src-card-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: white; flex-wrap: wrap; }
.src-n { width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.src-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.src-type { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; background: rgba(255,255,255,0.18); padding: 2px 8px; border-radius: 10px; }
.src-auth { font-size: 10.5px; opacity: 0.75; }

.src-card-body { padding: 10px 12px 12px; border-left: 3px solid transparent; }
.src-title { font-family: var(--serif); font-size: 13.5px; font-weight: 600; color: #111827; margin-bottom: 3px; }
.src-art   { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 8px; font-style: italic; }
.src-btns  { display: flex; flex-wrap: wrap; gap: 6px; }
.src-btn   { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 6px; font-size: 11.5px; font-weight: 600; font-family: var(--sans); cursor: pointer; transition: all 0.15s; white-space: nowrap; line-height: 1; }
.src-btn:active     { transform: scale(0.97); }
.src-btn-fill       { color: white; border: none; }
.src-btn-fill:hover { filter: brightness(1.15); }
.src-btn-line       { background: transparent; border: 1.5px solid; }
.src-btn-line:hover { background: rgba(0,0,0,0.04); }


/* ================================================================
   TYPING DOTS + RESEARCH STATUS
   ================================================================ */

.typing-dots { display: flex; gap: 4px; align-items: center; padding: 8px 0; }
.typing-dots span { width: 7px; height: 7px; background: var(--oxblood); opacity: 0.35; border-radius: 50%; animation: dotb 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.research-status {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px;
    background: #fdf5f5; border: 1px solid #fecaca;
    border-radius: 20px; width: fit-content; max-width: 340px;
    animation: fadeIn 0.3s ease;
}
.research-dots { display: flex; gap: 3px; align-items: center; flex-shrink: 0; }
.research-dots span { width: 5px; height: 5px; background: var(--oxblood); border-radius: 50%; animation: dotb 1.2s infinite; opacity: 0.5; }
.research-dots span:nth-child(2) { animation-delay: 0.2s; }
.research-dots span:nth-child(3) { animation-delay: 0.4s; }
.research-stage-icon  { font-size: 14px; flex-shrink: 0; line-height: 1; transition: all 0.3s ease; }
.research-stage-label { font-size: 12px; font-weight: 600; color: var(--oxblood); font-family: var(--sans); white-space: nowrap; transition: all 0.3s ease; }


/* ================================================================
   AUTH MODAL
   ================================================================ */

.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.60); backdrop-filter: blur(4px);
    z-index: 2000; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-overlay.active { display: flex !important; animation: fadeIn 0.25s ease; }

.modal-content {
    background: white; border-radius: 14px;
    width: 100%; max-width: 420px; padding: 30px;
    position: relative; box-shadow: 0 20px 50px rgba(0,0,0,0.28);
    animation: slideUp 0.25s ease;
}
.modal-close {
    position: absolute; top: 14px; right: 14px;
    background: transparent; border: none;
    color: var(--text-secondary); cursor: pointer;
    padding: 8px; border-radius: 8px; transition: all 0.2s; display: none;
}
.modal-close:hover { background: var(--parchment); }

.modal-header { text-align: center; margin-bottom: 24px; }
.modal-header h2 { font-family: var(--display); font-size: 21px; color: var(--text-primary); margin-bottom: 7px; }
.modal-header p  { font-size: 14px; color: var(--text-secondary); }

.auth-form { display: flex; flex-direction: column; gap: 15px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.form-group input {
    padding: 11px 13px; border: 1px solid var(--border-color);
    border-radius: 9px; font-size: 15px; font-family: var(--sans);
    outline: none; transition: all 0.2s;
}
.form-group input:focus { border-color: var(--oxblood); box-shadow: 0 0 0 3px var(--oxblood-light); }

.auth-submit-btn {
    background: var(--oxblood); color: white; border: none;
    padding: 13px; border-radius: 9px;
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: all 0.2s; margin-top: 6px; font-family: var(--sans);
}
.auth-submit-btn:hover:not(:disabled) { background: var(--oxblood-hover); transform: translateY(-1px); }
.auth-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-divider { text-align: center; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-color); font-size: 14px; color: var(--text-secondary); }
.auth-toggle-btn { background: transparent; border: none; color: var(--oxblood); cursor: pointer; font-size: 14px; font-weight: 600; padding: 3px 7px; margin-left: 4px; border-radius: 4px; transition: all 0.2s; }
.auth-toggle-btn:hover { background: var(--oxblood-light); }


/* ================================================================
   ARTICLE MODAL / SPINNER
   ================================================================ */

.spinner-box { background: white; border-radius: 12px; padding: 26px 30px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.spinner-box p { color: #374151; font-size: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid #e5e7eb; border-top-color: var(--oxblood); border-radius: 50%; animation: spin 0.7s linear infinite; }

.art-modal {
    background: white; border-radius: 13px;
    max-width: 740px; width: calc(100% - 32px);
    max-height: 86vh; display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 20px 55px rgba(0,0,0,0.24);
    animation: slideUp 0.22s ease;
}
.art-modal-hdr { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 24px; background: var(--oxblood); color: white; flex-shrink: 0; gap: 12px; }
.art-modal-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase; opacity: 0.65; margin-bottom: 3px; }
.art-modal-title { font-family: var(--display); font-size: 18px; font-weight: 700; }
.art-modal-cite  { font-size: 12px; opacity: 0.60; margin-top: 2px; font-style: italic; font-family: var(--serif); }
.art-modal-body  { overflow-y: auto; padding: 24px; flex: 1; }
.art-text { font-family: var(--serif); font-size: 15px; line-height: 1.9; color: #1f2937; white-space: pre-wrap; }


/* ================================================================
   KEYFRAMES
   ================================================================ */

@keyframes fadeIn    { from { opacity: 0; }              to { opacity: 1; } }
@keyframes slideIn   { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideUp   { from { opacity: 0; transform: translateY(10px);  } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin      { to   { transform: rotate(360deg); } }
@keyframes pulse     { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes dotb      { 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes shake     { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes fadeOut   { from { opacity: 1; } to { opacity: 0; } }


/* ================================================================
   RESPONSIVE BREAKPOINTS
   ================================================================ */

@media (max-width: 1023px) {
    :root { --content-max: 100%; --content-pad: 24px; }
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }
    .sidebar.active { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .input-anchor   { left: 0; }
    .mode-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 767px) {
    :root { --content-pad: 16px; --nav-h: 54px; }
    .top-nav { padding: 0 14px; }
    .nav-wordmark-tagline { display: none; }
    .nav-brand-divider    { display: none; }
    .nav-logo-img         { height: 28px; }
    .hourglass-container  { width: 22px; height: 22px; }
    .nav-wordmark-name    { font-size: 14px; }
    .nav-btn         { padding: 7px 10px; font-size: 12px; }
    .nav-btn-primary { padding: 7px 12px; font-size: 12px; }
    .messages { padding: 20px var(--content-pad) 140px; }
    .mode-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; }
    .mode-grid .mode-card:last-child:nth-child(5) { grid-column: 2 / 4; }
    .mode-card-bullets { display: none; }
    .mode-card-desc    { font-size: 10px; }
    .mode-card         { padding: 10px 8px; gap: 5px; }
    .mode-card-title   { font-size: 11px; }
    .mode-card-icon    { font-size: 17px; }
    .mode-indicator { display: flex; flex-wrap: wrap; gap: 7px; }
    .mode-exit-btn  { display: inline-flex; font-size: 11.5px; padding: 4px 10px; }
    .welcome-header h2 { font-size: 20px; }
    .welcome-header p  { font-size: 13px; }
    .input-container { padding: 0 var(--content-pad); }
    .input-anchor    { padding: 10px 0 18px; }
    textarea         { font-size: 16px; }
    .art-modal { max-height: 92vh; border-radius: 14px 14px 0 0; align-self: flex-end; width: 100%; }
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-content { border-radius: 14px 14px 0 0; max-width: 100%; }
    .welcome-screen { padding: 18px 0 0; }
    .user-msg { flex-direction: row; }
    .user-msg .msg-content { align-items: flex-start; }
    .user-text { border-radius: 4px 18px 18px 18px; }
    .ai-msg .msg-content { border-left: none; padding-left: 0; }
    .src-btns  { gap: 5px; }
    .src-btn   { padding: 5px 10px; font-size: 11px; }
    .draft-download-bar { flex-wrap: wrap; gap: 7px; }
    .draft-dl-btn--dismiss { margin-left: 0; }
    .sidebar.active { width: 280px; min-width: 280px; }
    .research-status { max-width: calc(100vw - 48px); }
}

@media (max-width: 479px) {
    :root { --content-pad: 12px; }
    .top-nav { padding: 0 12px; }
    .nav-logo-img    { height: 24px; }
    .nav-wordmark-name { font-size: 13px; }
    .nav-btn:not(.nav-btn-primary) { display: none; }
    .messages { padding: 14px var(--content-pad) 120px; }
    .mode-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
    .mode-grid .mode-card:last-child:nth-child(5) { grid-column: 2 / 4; }
    .mode-card       { padding: 8px 6px; gap: 4px; }
    .mode-card-title { font-size: 10px; }
    .mode-card-icon  { font-size: 15px; }
    .mode-card-desc  { display: none; }
    .msg { gap: 8px; }
    .msg-avatar { width: 28px; height: 28px; font-size: 11px; }
    .ai-body    { font-size: 14px; line-height: 1.78; }
    .input-box-wrapper { padding: 7px 9px; border-radius: 18px; }
    .send-btn    { width: 32px; height: 32px; border-radius: 7px; }
    .plus-icon   { font-size: 22px; }
    .input-anchor { padding: 8px 0 14px; }
    .footer-note { font-size: 10.5px; }
    .src-card-top  { padding: 7px 10px; }
    .src-card-body { padding: 8px 10px 10px; }
    .user-menu-dropdown { left: 8px; }
}

@media (hover: none) and (pointer: coarse) {
    .history-action-btn { padding: 5px 10px; }
    .src-btn            { padding: 8px 14px; min-height: 38px; }
    .nav-btn,
    .nav-btn-primary    { min-height: 44px; }
    .attachment-btn     { padding: 10px; }
    .send-btn           { width: 40px; height: 40px; }
    .history-item-footer { opacity: 1; }
    .history-action-btn  { opacity: 0.7; }
    .mode-card:hover     { transform: none; }
    .src-card:hover      { transform: none; }
    .nav-btn-primary:hover { transform: none; }
}

@media print {
    .sidebar, .top-nav, .input-anchor, .nav-actions { display: none !important; }
    .app-shell  { display: block; }
    .main-stage { width: 100%; }
    .chat-viewport { overflow: visible; height: auto; }
    .messages   { max-width: 100%; padding: 0; }
    .ai-body    { font-size: 12pt; line-height: 1.6; }
}/* ================================================================
   OLVERRA LEGAL — style.css  PRODUCTION v5.0
   Mobile-first responsive design.
   Every feature visible on desktop is visible on mobile.
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
    --oxblood:        #721c24;
    --oxblood-hover:  #5a161d;
    --oxblood-light:  rgba(114,28,36,0.10);
    --parchment:      #f9fafb;
    --pure-white:     #ffffff;
    --text-primary:   #111827;
    --text-secondary: #6b7280;
    --border-color:   #e5e7eb;
    --serif:          'Georgia', 'Times New Roman', serif;
    --sans:           -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --display:        'Playfair Display', 'Georgia', serif;
    --sidebar-w:      260px;
    --content-max:    860px;
    --content-pad:    40px;
    --nav-h:          60px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--sans);
    background: var(--parchment);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}
.app-shell { display: flex; height: 100vh; }


/* ================================================================
   SIDEBAR
   ================================================================ */

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--oxblood);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.15);
    z-index: 200;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-top { padding: 12px; flex-shrink: 0; }

.new-chat-btn {
    width: 100%;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.20);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-family: var(--sans);
    transition: all 0.2s;
}
.new-chat-btn:hover { background: rgba(255,255,255,0.16); }

/* ── History ─────────────────────────────────────────────────── */
.history-section {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 12px 12px;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.search-wrapper { position: relative; margin-bottom: 10px; }
.search-icon {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%); font-size: 13px; opacity: 0.5;
    pointer-events: none;
}
.search-wrapper input {
    width: 100%;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.15);
    padding: 8px 10px 8px 32px;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}
.search-wrapper input:focus {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.30);
}
.search-wrapper input::placeholder { color: rgba(255,255,255,0.45); }

/* ── History list ─────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 2px; }

.history-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.30);
    padding: 12px 4px 4px;
    pointer-events: none;
    user-select: none;
}

.history-item {
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
    color: rgba(255,255,255,0.82);
    font-size: 13px;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
}
.history-item:hover  { background: rgba(255,255,255,0.10); color: white; }
.history-item.active { background: rgba(255,255,255,0.16); color: white; }

.history-item-body {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}
.history-mode-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.85;
}
.history-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    line-height: 1.35;
}
.history-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 14px;
}
.history-item-time {
    font-size: 10.5px;
    color: rgba(255,255,255,0.32);
}
.history-action-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.28);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.15s;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}
.history-action-btn:hover { background: rgba(255,255,255,0.10); color: #ff6b6b; }

.history-empty {
    padding: 28px 12px;
    text-align: center;
}
.history-empty .empty-icon { font-size: 26px; opacity: 0.28; margin-bottom: 8px; }
.history-empty p { color: rgba(255,255,255,0.30); font-size: 12px; line-height: 1.55; }

.history-section::-webkit-scrollbar { width: 4px; }
.history-section::-webkit-scrollbar-track { background: transparent; }
.history-section::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

/* ── Sidebar footer ──────────────────────────────────────────── */
.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.12);
    flex-shrink: 0;
}
.user-profile {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: 8px;
    cursor: pointer; transition: all 0.2s;
}
.user-profile:hover { background: rgba(255,255,255,0.10); }
.user-profile .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 13px; font-weight: 600;
    flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name {
    display: block; color: white; font-size: 13px; font-weight: 500;
    font-family: var(--serif);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-menu-btn {
    background: transparent; border: none;
    color: rgba(255,255,255,0.55); cursor: pointer;
    padding: 4px; opacity: 0; transition: all 0.2s; flex-shrink: 0;
}
.user-profile:hover .user-menu-btn { opacity: 1; }

.user-menu-dropdown {
    position: fixed; bottom: 68px; left: 12px;
    background: white; border: 1px solid var(--border-color);
    border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 4px; display: none; z-index: 1100;
    min-width: 180px;
}
.user-menu-dropdown.active { display: block; animation: slideUp 0.2s ease; }
.user-menu-dropdown button {
    width: 100%; padding: 10px 14px;
    background: transparent; border: none; border-radius: 6px;
    cursor: pointer; display: flex; align-items: center; gap: 10px;
    color: var(--text-primary); font-size: 14px; font-family: var(--sans);
    transition: all 0.15s; text-align: left;
}
.user-menu-dropdown button:hover { background: var(--parchment); }


/* ================================================================
   MOBILE OVERLAY
   ================================================================ */

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.50);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; animation: fadeIn 0.2s ease; }


/* ================================================================
   TOP NAV
   ================================================================ */

.main-stage {
    flex: 1; display: flex; flex-direction: column;
    background: var(--pure-white); min-width: 0; overflow: hidden;
}

.top-nav {
    height: var(--nav-h);
    background: var(--pure-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 0 var(--border-color), 0 2px 8px rgba(0,0,0,0.03);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    gap: 12px;
}

.sidebar-toggle {
    display: none;
    background: transparent; border: none;
    color: var(--text-primary); cursor: pointer;
    padding: 8px; border-radius: 8px;
    font-size: 20px; line-height: 1;
    transition: background 0.2s;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--parchment); }

.nav-brand {
    display: flex; align-items: center; gap: 10px;
    cursor: default; flex-shrink: 0;
}
.nav-logo-img { height: 34px; width: auto; object-fit: contain; display: block; }
.nav-brand-divider {
    width: 1px; height: 26px;
    background: var(--border-color); flex-shrink: 0;
}
.hourglass-container { width: 26px; height: 26px; flex-shrink: 0; }
.hourglass-icon { width: 100%; height: 100%; }
.nav-wordmark { display: flex; flex-direction: column; gap: 1px; line-height: 1; }
.nav-wordmark-name {
    font-family: var(--display);
    font-size: 15px; font-weight: 700;
    color: var(--oxblood); letter-spacing: -0.01em;
}
.nav-wordmark-tagline {
    font-size: 9px; font-weight: 600;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: #b0b7c3;
}

.nav-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.nav-btn {
    background: transparent; border: none;
    color: var(--text-primary); padding: 8px 12px;
    border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 500; font-family: var(--sans);
    transition: all 0.2s; white-space: nowrap;
}
.nav-btn:hover { background: var(--parchment); }
.nav-btn-primary {
    background: var(--oxblood); border: none;
    color: white; padding: 8px 14px;
    border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 500; font-family: var(--sans);
    transition: all 0.2s; white-space: nowrap;
}
.nav-btn-primary:hover { background: var(--oxblood-hover); transform: translateY(-1px); }


/* ================================================================
   CHAT VIEWPORT
   ================================================================ */

.chat-viewport {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    background: var(--pure-white);
    -webkit-overflow-scrolling: touch;
}
.chat-viewport::-webkit-scrollbar { width: 5px; }
.chat-viewport::-webkit-scrollbar-track { background: transparent; }
.chat-viewport::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.chat-viewport::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

.messages {
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    padding: 32px var(--content-pad) 160px;
}


/* ================================================================
   MESSAGES
   ================================================================ */

.msg {
    margin-bottom: 28px;
    display: flex;
    gap: 12px;
    animation: fadeIn 0.22s ease;
    width: 100%;
}

.user-msg { flex-direction: row-reverse; }
.user-msg .msg-content { align-items: flex-end; }
.ai-msg { flex-direction: row; }

.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 2px;
}
.ai-msg .msg-avatar   { background: var(--oxblood); color: white; }
.ai-msg .msg-avatar svg { width: 17px; height: 17px; }
.user-msg .msg-avatar {
    background: #374151; color: white;
    font-weight: 600; font-size: 13px;
}

.msg-content {
    flex: 1; min-width: 0;
    overflow-wrap: break-word; word-break: break-word;
}
.ai-msg .msg-content {
    border-left: 2px solid rgba(114,28,36,0.10);
    padding-left: 14px;
}

.user-text {
    background: var(--oxblood); color: white;
    padding: 10px 16px;
    border-radius: 18px 18px 4px 18px;
    display: inline-block; max-width: 100%;
    word-break: break-word;
    font-size: 14.5px; line-height: 1.55;
    box-shadow: 0 1px 4px rgba(114,28,36,0.18);
}

.msg-meta {
    font-size: 11px; color: #b0b7c3;
    margin-top: 5px; font-family: var(--sans);
}
.msg-meta--user { text-align: right; }

.msg-mode-badge {
    display: inline-block; color: white;
    font-size: 10px; font-weight: 700;
    padding: 2px 10px; border-radius: 12px;
    letter-spacing: 0.06em; text-transform: uppercase;
    margin-bottom: 10px; font-family: var(--sans);
}

.typing-indicator .msg-content { animation: pulse 1.5s ease-in-out infinite; }


/* ================================================================
   AI BODY
   ================================================================ */

.ai-body {
    font-family: var(--serif);
    font-size: 15px; line-height: 1.88; color: #1a1a1a;
    overflow-wrap: break-word; word-break: break-word;
}
.ai-body p            { margin: 0 0 0.85em; white-space: normal; }
.ai-body p:last-child { margin-bottom: 0; }
.ai-body li           { white-space: normal; }
.ai-body blockquote   { white-space: normal; }

.ai-body pre, .ai-body .draft-pre {
    white-space: pre-wrap; word-break: break-all; overflow-x: auto;
    font-family: 'Courier New', monospace; font-size: 12.5px;
    background: #f9fafb; border: 1px solid var(--border-color);
    border-radius: 6px; padding: 12px 14px; margin: 8px 0;
}

.irac-head {
    display: flex; align-items: center; gap: 10px;
    background: var(--oxblood); color: white;
    font-family: var(--sans); font-size: 10.5px; font-weight: 800;
    letter-spacing: 0.12em; text-transform: uppercase;
    padding: 8px 14px; border-radius: 5px; margin: 22px 0 10px;
    flex-wrap: wrap;
}
.irac-num { opacity: 0.6; font-weight: 400; font-style: italic; text-transform: none; letter-spacing: 0; font-size: 12px; }
.alpha-head {
    display: flex; align-items: baseline; gap: 8px;
    font-size: 14px; font-weight: 700; color: var(--oxblood);
    margin: 18px 0 7px; padding-bottom: 4px;
    border-bottom: 2px solid #fecaca; flex-wrap: wrap;
}
.alpha-num { color: #b91c1c; font-style: italic; font-weight: 400; }
.num-head { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: #374151; margin: 14px 0 5px; }
.num-badge { background: #fee2e2; color: #991b1b; font-size: 11px; font-weight: 700; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

.legal-ul, .legal-ol { margin: 6px 0 10px; padding-left: 20px; }
.legal-ul li, .legal-ol li { margin-bottom: 5px; line-height: 1.7; color: #374151; }
.legal-sub { list-style: none; margin: 4px 0 8px 10px; padding: 0; }
.legal-sub li { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; font-size: 14px; color: #4b5563; }
.sub-lbl { color: #6b7280; font-style: italic; min-width: 26px; flex-shrink: 0; }

.legal-bq {
    margin: 10px 0; padding: 10px 14px;
    background: #fdf5f5; border-left: 3px solid var(--oxblood);
    font-style: italic; color: #3d1a1e;
    font-size: 13.5px; line-height: 1.8; border-radius: 0 5px 5px 0;
}

.ai-body h2.md-head, .ai-body h3.md-head {
    font-family: var(--display); color: var(--oxblood);
    letter-spacing: -0.01em; margin: 18px 0 8px;
}

.limit-lbl {
    display: inline-block; background: #fef3c7; color: #92400e;
    font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
    padding: 1px 6px; border-radius: 3px; margin-right: 5px; vertical-align: middle;
}
.icode { background: #f3f4f6; color: #111; font-family: monospace; font-size: 12px; padding: 1px 5px; border-radius: 3px; border: 1px solid #e5e7eb; }
.src-ref {
    display: inline-flex; align-items: center;
    background: var(--oxblood); color: #fff !important;
    font-size: 11px; font-weight: 700;
    padding: 1px 7px; border-radius: 10px;
    text-decoration: none !important; margin: 0 2px;
    vertical-align: middle; cursor: pointer; transition: background 0.15s;
}
.src-ref:hover { background: var(--oxblood-hover); }


/* ================================================================
   WELCOME SCREEN + MODE SELECTOR
   ================================================================ */

.welcome-screen { padding: 32px 0 0; animation: fadeIn 0.4s ease; }

.welcome-header { text-align: center; margin-bottom: 28px; }
.welcome-icon { width: 52px; height: 52px; margin: 0 auto 14px; }
.welcome-icon svg { width: 100%; height: 100%; }
.welcome-header h2 {
    font-family: var(--display);
    color: var(--oxblood);
    font-size: 26px; font-weight: 700;
    margin-bottom: 5px; letter-spacing: -0.02em;
}
.welcome-header p {
    color: var(--text-secondary); font-size: 14px;
    font-style: italic; font-family: var(--serif);
}

.mode-selector-label {
    text-align: center; font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: #b0b7c3; margin-bottom: 12px;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.mode-card {
    background: var(--pure-white);
    border: 1.5px solid var(--border-color);
    border-radius: 10px; padding: 14px 12px;
    cursor: pointer; text-align: left;
    transition: all 0.18s ease;
    display: flex; flex-direction: column; gap: 8px;
    position: relative; overflow: hidden;
}
.mode-card::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 2.5px;
    background: var(--oxblood);
    transform: scaleX(0); transform-origin: left;
    transition: transform 0.18s ease;
}
.mode-card:hover { border-color: var(--oxblood); box-shadow: 0 4px 14px rgba(114,28,36,0.10); transform: translateY(-2px); }
.mode-card:hover::before   { transform: scaleX(1); }
.mode-card--active         { border-color: var(--oxblood); background: #fdf5f5; }
.mode-card--active::before { transform: scaleX(1); }

.mode-card-icon    { font-size: 20px; line-height: 1; }
.mode-card-title   { font-family: var(--serif); font-size: 12.5px; font-weight: 700; color: #1a1a1a; margin-bottom: 3px; }
.mode-card-desc    { font-size: 10.5px; color: var(--text-secondary); line-height: 1.4; }
.mode-card-bullets { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 3px; }
.mode-card-bullets li { font-size: 10px; color: #7a8393; padding-left: 10px; position: relative; line-height: 1.4; }
.mode-card-bullets li::before { content: '›'; position: absolute; left: 0; color: var(--oxblood); font-weight: 700; }

.mode-indicator { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode-badge {
    background: var(--oxblood); color: white;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.07em; text-transform: uppercase;
    padding: 3px 12px; border-radius: 20px;
}
.mode-exit-btn {
    background: transparent; border: 1px solid var(--border-color);
    color: var(--text-secondary); font-size: 12px;
    padding: 3px 10px; border-radius: 6px;
    cursor: pointer; transition: all 0.2s; font-family: var(--sans);
}
.mode-exit-btn:hover { background: var(--parchment); color: var(--oxblood); border-color: var(--oxblood); }
.input-box-wrapper.mode-active {
    border-color: var(--oxblood);
    box-shadow: 0 0 0 2.5px rgba(114,28,36,0.08);
}


/* ================================================================
   INPUT AREA
   ================================================================ */

.input-anchor {
    position: fixed; bottom: 0;
    left: var(--sidebar-w); right: 0;
    background: linear-gradient(to top, var(--pure-white) 82%, transparent);
    padding: 14px 0 24px;
    z-index: 50;
}

.input-container {
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--content-pad);
}

.attachment-warning {
    display: none;
    background: #fffbeb; border: 1px solid #f59e0b;
    border-radius: 8px; padding: 7px 12px; margin-bottom: 8px;
    gap: 8px; align-items: flex-start;
    animation: slideDown 0.3s ease;
}
.attachment-warning.active { display: flex; }
.attachment-warning-icon   { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.attachment-warning-text   { flex: 1; font-size: 12px; color: #92400e; line-height: 1.5; }
.attachment-warning-text strong { font-weight: 700; color: #78350f; }
.attachment-warning-close {
    background: transparent; border: none;
    color: #b45309; cursor: pointer; font-size: 15px;
    padding: 0 3px; flex-shrink: 0; line-height: 1; opacity: 0.75;
}
.attachment-warning-close:hover { opacity: 1; }

.draft-download-bar {
    background: #fff8f8; border: 1px solid #fecaca;
    border-radius: 10px; padding: 9px 14px; margin-bottom: 8px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    animation: slideDown 0.3s ease;
}
.draft-download-label { font-size: 13px; font-weight: 600; color: var(--oxblood); flex-shrink: 0; }
.draft-dl-btn {
    background: var(--oxblood); color: white; border: none;
    padding: 5px 14px; border-radius: 6px;
    font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--sans);
    transition: all 0.2s;
}
.draft-dl-btn:hover         { background: var(--oxblood-hover); transform: translateY(-1px); }
.draft-dl-btn--pdf          { background: #1e3a5f; }
.draft-dl-btn--pdf:hover    { background: #162d4a; }
.draft-dl-btn--dismiss      { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); margin-left: auto; font-size: 16px; padding: 3px 10px; }
.draft-dl-btn--dismiss:hover { background: var(--parchment); transform: none; }

.file-preview {
    display: none;
    background: var(--oxblood-light); border: 1px solid var(--oxblood);
    border-radius: 10px; padding: 8px 12px; margin-bottom: 8px;
    align-items: center; gap: 10px;
    animation: slideDown 0.3s ease;
}
.file-preview.active { display: flex; }
.file-info { flex: 1; display: flex; align-items: center; gap: 7px; color: var(--oxblood); font-size: 13px; min-width: 0; }
.file-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--text-secondary); flex-shrink: 0; font-size: 12px; }
.remove-file-btn {
    background: transparent; border: none; color: var(--oxblood);
    cursor: pointer; padding: 4px; border-radius: 4px; flex-shrink: 0;
    transition: all 0.2s;
}
.remove-file-btn:hover { background: rgba(114,28,36,0.15); }

.input-box-wrapper {
    background: var(--pure-white); border: 1px solid var(--border-color);
    border-radius: 22px; padding: 8px 10px;
    display: flex; align-items: flex-end; gap: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); transition: all 0.2s;
}
.input-box-wrapper:focus-within {
    border-color: var(--oxblood);
    box-shadow: 0 0 0 3px rgba(114,28,36,0.08);
}

.attachment-btn {
    background: transparent; border: none; cursor: pointer;
    padding: 7px; border-radius: 8px; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.attachment-btn:hover { background: #f3f4f6; }
.plus-icon { font-size: 26px; font-weight: 300; color: #374151; line-height: 1; }

textarea {
    flex: 1; border: none; outline: none; resize: none;
    font-family: var(--sans); font-size: 15px; line-height: 1.5;
    color: var(--text-primary); background: transparent;
    max-height: 180px; padding: 7px 0; min-width: 0;
}
textarea::placeholder { color: var(--text-secondary); }

.send-btn {
    background: #111111; border: none;
    width: 34px; height: 34px; border-radius: 8px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, transform 0.2s; flex-shrink: 0;
}
.send-btn:hover    { filter: brightness(1.3); transform: translateY(-1px); }
.send-btn:disabled { background: var(--border-color); cursor: not-allowed; transform: none; }
.send-btn.cancel   { background: #dc2626; }
.send-btn.cancel:hover { background: #b91c1c; transform: translateY(-1px); }
.arrow-icon { font-size: 18px; color: white; font-weight: bold; line-height: 1; }

.footer-note {
    text-align: center; font-size: 11.5px; color: #b0b7c3;
    margin-top: 8px; font-family: var(--serif); font-style: italic;
}


/* ================================================================
   SOURCE CARDS
   ================================================================ */

.sources-wrap { margin-top: 18px; padding-top: 12px; border-top: 2px solid #f3f4f6; }
.sources-hdr { font-family: var(--sans); font-size: 10.5px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; }
.sources-list { display: flex; flex-direction: column; gap: 8px; }

.src-card { border-radius: 9px; overflow: hidden; border: 1px solid var(--border-color); background: white; transition: box-shadow 0.2s, transform 0.2s; }
.src-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.09); transform: translateY(-1px); }
.src-card.hl    { box-shadow: 0 0 0 3px #fbbf24, 0 3px 12px rgba(0,0,0,0.10); }

.src-card-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: white; flex-wrap: wrap; }
.src-n { width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.src-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.src-type { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; background: rgba(255,255,255,0.18); padding: 2px 8px; border-radius: 10px; }
.src-auth { font-size: 10.5px; opacity: 0.75; }

.src-card-body { padding: 10px 12px 12px; border-left: 3px solid transparent; }
.src-title { font-family: var(--serif); font-size: 13.5px; font-weight: 600; color: #111827; margin-bottom: 3px; }
.src-art   { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 8px; font-style: italic; }
.src-btns  { display: flex; flex-wrap: wrap; gap: 6px; }
.src-btn   { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 6px; font-size: 11.5px; font-weight: 600; font-family: var(--sans); cursor: pointer; transition: all 0.15s; white-space: nowrap; line-height: 1; }
.src-btn:active     { transform: scale(0.97); }
.src-btn-fill       { color: white; border: none; }
.src-btn-fill:hover { filter: brightness(1.15); }
.src-btn-line       { background: transparent; border: 1.5px solid; }
.src-btn-line:hover { background: rgba(0,0,0,0.04); }


/* ================================================================
   TYPING DOTS + RESEARCH STATUS
   ================================================================ */

.typing-dots { display: flex; gap: 4px; align-items: center; padding: 8px 0; }
.typing-dots span { width: 7px; height: 7px; background: var(--oxblood); opacity: 0.35; border-radius: 50%; animation: dotb 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.research-status {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px;
    background: #fdf5f5; border: 1px solid #fecaca;
    border-radius: 20px; width: fit-content; max-width: 340px;
    animation: fadeIn 0.3s ease;
}
.research-dots { display: flex; gap: 3px; align-items: center; flex-shrink: 0; }
.research-dots span { width: 5px; height: 5px; background: var(--oxblood); border-radius: 50%; animation: dotb 1.2s infinite; opacity: 0.5; }
.research-dots span:nth-child(2) { animation-delay: 0.2s; }
.research-dots span:nth-child(3) { animation-delay: 0.4s; }
.research-stage-icon  { font-size: 14px; flex-shrink: 0; line-height: 1; transition: all 0.3s ease; }
.research-stage-label { font-size: 12px; font-weight: 600; color: var(--oxblood); font-family: var(--sans); white-space: nowrap; transition: all 0.3s ease; }


/* ================================================================
   AUTH MODAL
   ================================================================ */

.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.60); backdrop-filter: blur(4px);
    z-index: 2000; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-overlay.active { display: flex !important; animation: fadeIn 0.25s ease; }

.modal-content {
    background: white; border-radius: 14px;
    width: 100%; max-width: 420px; padding: 30px;
    position: relative; box-shadow: 0 20px 50px rgba(0,0,0,0.28);
    animation: slideUp 0.25s ease;
}
.modal-close {
    position: absolute; top: 14px; right: 14px;
    background: transparent; border: none;
    color: var(--text-secondary); cursor: pointer;
    padding: 8px; border-radius: 8px; transition: all 0.2s; display: none;
}
.modal-close:hover { background: var(--parchment); }

.modal-header { text-align: center; margin-bottom: 24px; }
.modal-header h2 { font-family: var(--display); font-size: 21px; color: var(--text-primary); margin-bottom: 7px; }
.modal-header p  { font-size: 14px; color: var(--text-secondary); }

.auth-form { display: flex; flex-direction: column; gap: 15px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.form-group input {
    padding: 11px 13px; border: 1px solid var(--border-color);
    border-radius: 9px; font-size: 15px; font-family: var(--sans);
    outline: none; transition: all 0.2s;
}
.form-group input:focus { border-color: var(--oxblood); box-shadow: 0 0 0 3px var(--oxblood-light); }

.auth-submit-btn {
    background: var(--oxblood); color: white; border: none;
    padding: 13px; border-radius: 9px;
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: all 0.2s; margin-top: 6px; font-family: var(--sans);
}
.auth-submit-btn:hover:not(:disabled) { background: var(--oxblood-hover); transform: translateY(-1px); }
.auth-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-divider { text-align: center; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-color); font-size: 14px; color: var(--text-secondary); }
.auth-toggle-btn { background: transparent; border: none; color: var(--oxblood); cursor: pointer; font-size: 14px; font-weight: 600; padding: 3px 7px; margin-left: 4px; border-radius: 4px; transition: all 0.2s; }
.auth-toggle-btn:hover { background: var(--oxblood-light); }


/* ================================================================
   ARTICLE MODAL / SPINNER
   ================================================================ */

.spinner-box { background: white; border-radius: 12px; padding: 26px 30px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.spinner-box p { color: #374151; font-size: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid #e5e7eb; border-top-color: var(--oxblood); border-radius: 50%; animation: spin 0.7s linear infinite; }

.art-modal {
    background: white; border-radius: 13px;
    max-width: 740px; width: calc(100% - 32px);
    max-height: 86vh; display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 20px 55px rgba(0,0,0,0.24);
    animation: slideUp 0.22s ease;
}
.art-modal-hdr { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 24px; background: var(--oxblood); color: white; flex-shrink: 0; gap: 12px; }
.art-modal-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase; opacity: 0.65; margin-bottom: 3px; }
.art-modal-title { font-family: var(--display); font-size: 18px; font-weight: 700; }
.art-modal-cite  { font-size: 12px; opacity: 0.60; margin-top: 2px; font-style: italic; font-family: var(--serif); }
.art-modal-body  { overflow-y: auto; padding: 24px; flex: 1; }
.art-text { font-family: var(--serif); font-size: 15px; line-height: 1.9; color: #1f2937; white-space: pre-wrap; }


/* ================================================================
   KEYFRAMES
   ================================================================ */

@keyframes fadeIn    { from { opacity: 0; }              to { opacity: 1; } }
@keyframes slideIn   { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideUp   { from { opacity: 0; transform: translateY(10px);  } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin      { to   { transform: rotate(360deg); } }
@keyframes pulse     { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes dotb      { 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes shake     { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes fadeOut   { from { opacity: 1; } to { opacity: 0; } }


/* ================================================================
   RESPONSIVE BREAKPOINTS
   ================================================================ */

@media (max-width: 1023px) {
    :root { --content-max: 100%; --content-pad: 24px; }
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }
    .sidebar.active { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .input-anchor   { left: 0; }
    .mode-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 767px) {
    :root { --content-pad: 16px; --nav-h: 54px; }
    .top-nav { padding: 0 14px; }
    .nav-wordmark-tagline { display: none; }
    .nav-brand-divider    { display: none; }
    .nav-logo-img         { height: 28px; }
    .hourglass-container  { width: 22px; height: 22px; }
    .nav-wordmark-name    { font-size: 14px; }
    .nav-btn         { padding: 7px 10px; font-size: 12px; }
    .nav-btn-primary { padding: 7px 12px; font-size: 12px; }
    .messages { padding: 20px var(--content-pad) 140px; }
    .mode-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; }
    .mode-grid .mode-card:last-child:nth-child(5) { grid-column: 2 / 4; }
    .mode-card-bullets { display: none; }
    .mode-card-desc    { font-size: 10px; }
    .mode-card         { padding: 10px 8px; gap: 5px; }
    .mode-card-title   { font-size: 11px; }
    .mode-card-icon    { font-size: 17px; }
    .mode-indicator { display: flex; flex-wrap: wrap; gap: 7px; }
    .mode-exit-btn  { display: inline-flex; font-size: 11.5px; padding: 4px 10px; }
    .welcome-header h2 { font-size: 20px; }
    .welcome-header p  { font-size: 13px; }
    .input-container { padding: 0 var(--content-pad); }
    .input-anchor    { padding: 10px 0 18px; }
    textarea         { font-size: 16px; }
    .art-modal { max-height: 92vh; border-radius: 14px 14px 0 0; align-self: flex-end; width: 100%; }
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-content { border-radius: 14px 14px 0 0; max-width: 100%; }
    .welcome-screen { padding: 18px 0 0; }
    .user-msg { flex-direction: row; }
    .user-msg .msg-content { align-items: flex-start; }
    .user-text { border-radius: 4px 18px 18px 18px; }
    .ai-msg .msg-content { border-left: none; padding-left: 0; }
    .src-btns  { gap: 5px; }
    .src-btn   { padding: 5px 10px; font-size: 11px; }
    .draft-download-bar { flex-wrap: wrap; gap: 7px; }
    .draft-dl-btn--dismiss { margin-left: 0; }
    .sidebar.active { width: 280px; min-width: 280px; }
    .research-status { max-width: calc(100vw - 48px); }
}

@media (max-width: 479px) {
    :root { --content-pad: 12px; }
    .top-nav { padding: 0 12px; }
    .nav-logo-img    { height: 24px; }
    .nav-wordmark-name { font-size: 13px; }
    .nav-btn:not(.nav-btn-primary) { display: none; }
    .messages { padding: 14px var(--content-pad) 120px; }
    .mode-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
    .mode-grid .mode-card:last-child:nth-child(5) { grid-column: 2 / 4; }
    .mode-card       { padding: 8px 6px; gap: 4px; }
    .mode-card-title { font-size: 10px; }
    .mode-card-icon  { font-size: 15px; }
    .mode-card-desc  { display: none; }
    .msg { gap: 8px; }
    .msg-avatar { width: 28px; height: 28px; font-size: 11px; }
    .ai-body    { font-size: 14px; line-height: 1.78; }
    .input-box-wrapper { padding: 7px 9px; border-radius: 18px; }
    .send-btn    { width: 32px; height: 32px; border-radius: 7px; }
    .plus-icon   { font-size: 22px; }
    .input-anchor { padding: 8px 0 14px; }
    .footer-note { font-size: 10.5px; }
    .src-card-top  { padding: 7px 10px; }
    .src-card-body { padding: 8px 10px 10px; }
    .user-menu-dropdown { left: 8px; }
}

@media (hover: none) and (pointer: coarse) {
    .history-action-btn { padding: 5px 10px; }
    .src-btn            { padding: 8px 14px; min-height: 38px; }
    .nav-btn,
    .nav-btn-primary    { min-height: 44px; }
    .attachment-btn     { padding: 10px; }
    .send-btn           { width: 40px; height: 40px; }
    .history-item-footer { opacity: 1; }
    .history-action-btn  { opacity: 0.7; }
    .mode-card:hover     { transform: none; }
    .src-card:hover      { transform: none; }
    .nav-btn-primary:hover { transform: none; }
}

@media print {
    .sidebar, .top-nav, .input-anchor, .nav-actions { display: none !important; }
    .app-shell  { display: block; }
    .main-stage { width: 100%; }
    .chat-viewport { overflow: visible; height: auto; }
    .messages   { max-width: 100%; padding: 0; }
    .ai-body    { font-size: 12pt; line-height: 1.6; }
}