/* ============================================================
   WELLNESS ORACLE — UPGRADED UI (Claude-inspired)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Serif+Display:ital@0;1&display=swap');

:root {
    --color-primary: #20a898;
    --color-primary-dark: #1a8a7a;
    --color-primary-light: rgba(32,168,152,0.12);
    --color-bg: #ffffff;
    --color-sidebar: #f5f5f0;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-text-secondary: #6b7280;
    --color-border: #e5e5e0;
    --color-hover: #f0f0ea;
    --color-danger: #dc2626;
    --color-oracle-bubble: #f7f7f5;
    --color-user-bubble: #20a898;
    --sidebar-width: 272px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --chat-font-size: 15px;
}

.dark-mode {
    --color-bg: #1a1a1a;
    --color-sidebar: #111111;
    --color-surface: #242424;
    --color-text: #ececec;
    --color-text-secondary: #9ca3af;
    --color-border: #2e2e2e;
    --color-hover: #2a2a2a;
    --color-oracle-bubble: #242424;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-secondary); }

/* ── ICONS ── */
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ── APP LAYOUT ── */
.app-container { display: flex; height: 100vh; height: 100dvh; position: relative; overflow: hidden; }

/* ── OVERLAY ── */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
    z-index: 998; opacity: 0; transition: opacity var(--transition);
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), width 0.3s cubic-bezier(0.4,0,0.2,1), min-width 0.3s cubic-bezier(0.4,0,0.2,1), border 0.3s;
    z-index: 999; height: 100vh; height: 100dvh;
    overflow: hidden; flex-shrink: 0;
}

/* Header */
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }

.logo-section { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.logo-content { display: flex; align-items: center; gap: 10px; text-decoration: none; }

.logo-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, #003d7a, #20a898);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(32,168,152,0.3);
}
.sidebar-logo { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }

.brand-text h1 {
    font-size: 15px; font-weight: 600; color: var(--color-text);
    letter-spacing: -0.2px; line-height: 1.2;
}
.brand-text span { font-size: 11px; color: var(--color-text-secondary); font-weight: 400; }

.close-sidebar-btn {
    display: flex; background: none; border: none; cursor: pointer;
    padding: 6px; color: var(--color-text-secondary); border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    align-items: center; justify-content: center;
}
.close-sidebar-btn:hover { background: var(--color-hover); color: var(--color-text); }

/* New Chat Button */
.new-chat-btn {
    width: 100%; padding: 10px 14px;
    background: var(--color-primary); color: white; border: none;
    border-radius: var(--radius-md); font-size: 13.5px; font-weight: 500;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    font-family: inherit;
}
.new-chat-btn:hover { background: var(--color-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(32,168,152,0.3); }
.new-chat-btn:active { transform: translateY(0); }

/* ── AUTH SECTION ── */
.auth-section { padding: 12px 16px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.auth-buttons { display: flex; gap: 8px; }

.login-btn, .signup-btn {
    flex: 1; padding: 9px; border-radius: var(--radius-sm);
    font-size: 13px; cursor: pointer; transition: all var(--transition);
    font-family: inherit; font-weight: 500;
}
.login-btn { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.login-btn:hover { background: var(--color-hover); border-color: var(--color-text-secondary); }
.signup-btn { background: var(--color-primary); color: white; border: 1px solid var(--color-primary); }
.signup-btn:hover { background: var(--color-primary-dark); }

/* ── USER SECTION ── */
/* user-section moved to sidebar-footer — see bottom of file */

.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; flex-shrink: 0; letter-spacing: 0.5px;
}
.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 600; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: 11px; color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }

.user-actions { display: flex; flex-direction: column; gap: 5px; }
.user-action-btn {
    width: 100%; padding: 8px 10px; background: transparent;
    border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    font-size: 12.5px; cursor: pointer; display: flex; align-items: center; gap: 7px;
    color: var(--color-text); transition: all var(--transition); font-family: inherit;
}
.user-action-btn:hover { background: var(--color-hover); }
.delete-account-btn { color: var(--color-danger); border-color: transparent; }
.delete-account-btn:hover { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.2); }

/* ── SIDEBAR CONTENT (history) ── */
.sidebar-content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 12px; min-height: 0; }
.section-title { font-size: 11px; font-weight: 600; color: var(--color-text-secondary); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px; padding: 0 4px; }
.chat-history { display: flex; flex-direction: column; gap: 2px; }

.empty-history {
    text-align: center; color: var(--color-text-secondary); font-size: 13px;
    padding: 28px 12px; border: 1px dashed var(--color-border);
    border-radius: var(--radius-md); background: var(--color-hover); line-height: 1.5;
}

.chat-history-item {
    display: flex; align-items: center; gap: 4px;
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
    color: var(--color-text); overflow: hidden;
    border: 1px solid transparent;
}
.chat-history-item:hover { background: var(--color-hover); border-color: var(--color-border); }
.chat-history-item.active { background: var(--color-primary-light); border-color: rgba(32,168,152,0.25); }

.chat-history-item-body { flex: 1; min-width: 0; padding: 9px 8px; }
.chat-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }
.chat-history-item.active .chat-title { color: var(--color-primary-dark); font-weight: 600; }
.chat-meta { font-size: 11px; color: var(--color-text-secondary); }

.chat-delete-btn {
    flex-shrink: 0; width: 26px; height: 26px; margin-right: 5px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; border-radius: var(--radius-sm);
    color: var(--color-danger); cursor: pointer; opacity: 0; transition: opacity var(--transition), background var(--transition);
}
.chat-history-item:hover .chat-delete-btn { opacity: 1; }
.chat-delete-btn:hover { background: rgba(220,38,38,0.1); }
@media (hover: none) and (pointer: coarse) { .chat-delete-btn { opacity: 1; } }

/* ── SIDEBAR COLLAPSED (desktop) ── */
.app-container.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right: none;
}
.app-container.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* ── SIDEBAR SEARCH ── */
.sidebar-search-row {
    padding: 0 0 10px 0;
}
.sidebar-search-wrap {
    display: flex; align-items: center;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 7px 10px; gap: 7px;
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: text;
}
.sidebar-search-wrap:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(32,168,152,0.1);
    outline: none;
}
.sidebar-search-icon {
    width: 14px; height: 14px; flex-shrink: 0;
    color: var(--color-text-secondary); stroke-width: 2;
}
.sidebar-search-input {
    flex: 1; border: none; background: transparent;
    font-size: 12.5px; color: var(--color-text);
    font-family: inherit; outline: none; min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}
.sidebar-search-input::placeholder { color: var(--color-text-secondary); }
.sidebar-search-input:focus { outline: none; box-shadow: none; }
.sidebar-search-clear {
    background: none; border: none; cursor: pointer; padding: 1px;
    color: var(--color-text-secondary); display: flex; align-items: center;
    border-radius: 4px; transition: color var(--transition);
    flex-shrink: 0;
}
.sidebar-search-clear:hover { color: var(--color-text); }
.chat-history-item.search-hidden { display: none; }

/* Highlight matched text in search */
.chat-title mark {
    background: rgba(32,168,152,0.2);
    color: var(--color-primary-dark);
    border-radius: 2px; padding: 0 1px;
    font-weight: 600;
}


.sidebar-footer {
    padding: 10px 12px; border-top: 1px solid var(--color-border);
    flex-shrink: 0; background: var(--color-sidebar);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.action-btn {
    width: 100%; padding: 9px 10px; background: transparent;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    font-size: 12.5px; cursor: pointer; display: flex; align-items: center; gap: 8px;
    color: var(--color-text-secondary); transition: all var(--transition); margin-bottom: 2px;
    font-family: inherit;
}
.action-btn:hover { background: var(--color-hover); color: var(--color-text); }
.action-btn.danger { color: var(--color-danger); }
.action-btn.danger:hover { background: rgba(220,38,38,0.08); }

/* ═══════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════ */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; min-width: 0; }

/* Top Bar */
.top-bar {
    padding: 12px 20px; border-bottom: 1px solid var(--color-border);
    background: var(--color-surface); display: flex; align-items: center;
    justify-content: space-between; flex-shrink: 0; z-index: 10;
}
.top-bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.menu-btn {
    display: flex; background: none; border: none; cursor: pointer;
    padding: 7px; color: var(--color-text); border-radius: var(--radius-sm);
    transition: background var(--transition); flex-shrink: 0;
    align-items: center; justify-content: center;
}
.menu-btn:hover { background: var(--color-hover); }
.chat-title-main { font-size: 15px; font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-controls { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
    width: 36px; height: 36px; background: transparent; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center;
    justify-content: center; transition: all var(--transition); color: var(--color-text-secondary);
}
.icon-btn:hover { background: var(--color-hover); color: var(--color-text); }

/* ── CHAT AREA ── */
.chat-area {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 24px 20px; padding-bottom: 20px;
    display: flex; flex-direction: column;
    align-items: center;
    scroll-behavior: smooth;
}

/* ── WELCOME SECTION (Home) ── */
.welcome-section {
    max-width: 680px; width: 100%; margin: auto;
    padding: 40px 0 20px;
    display: flex; flex-direction: column; align-items: center;
    animation: fadeInUp 0.5s ease both;
}

/* ── WELCOME INPUT (centered on homepage) ── */
.welcome-input-wrap {
    width: 100%; max-width: 640px;
    margin: 24px 0 20px;
}
.welcome-input-wrap .input-container {
    width: 100%;
}

/* Smooth transition when input moves to bottom */
.input-container {
    transition: none;
}

/* Bottom input-area (after first message) */
#bottomInputArea {
    padding: 8px 20px 12px;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    animation: inputSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes inputSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.welcome-logo-wrap {
    width: 72px; height: 72px; border-radius: 20px;
    background: linear-gradient(135deg, #003d7a, #20a898);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(32,168,152,0.25);
    animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 8px 32px rgba(32,168,152,0.25); }
    50%       { box-shadow: 0 8px 40px rgba(32,168,152,0.45); }
}
.welcome-logo-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 20px; }

.welcome-greeting {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 28px; color: var(--color-text); text-align: center;
    margin-bottom: 8px; line-height: 1.25;
}
.welcome-sub {
    font-size: 15px; color: var(--color-text-secondary); text-align: center;
    margin-bottom: 36px; line-height: 1.6; max-width: 440px;
}

/* Suggestion chips — shown on homepage */
.suggestion-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 600px;
    margin-top: 8px;
}
.chip {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); padding: 14px 16px; cursor: pointer;
    transition: all var(--transition); text-align: left;
    animation: fadeInUp 0.5s ease both;
}
.chip:nth-child(1) { animation-delay: 0.05s; }
.chip:nth-child(2) { animation-delay: 0.10s; }
.chip:nth-child(3) { animation-delay: 0.15s; }
.chip:nth-child(4) { animation-delay: 0.20s; }
.chip:hover { border-color: var(--color-primary); background: var(--color-primary-light); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(32,168,152,0.12); }
.chip-icon { font-size: 20px; margin-bottom: 6px; display: block; }
.chip-title { font-size: 13.5px; font-weight: 600; color: var(--color-text); margin-bottom: 3px; }
.chip-desc { font-size: 12px; color: var(--color-text-secondary); line-height: 1.4; }

/* OLD feature cards (kept for back-compat, hidden on new UI) */
.features-grid { display: none; }
.welcome-message { display: none; }

/* ── MESSAGES CONTAINER ── */
.messages-container {
    max-width: 740px; width: 100%; margin: 0 auto;
    display: flex; flex-direction: column; gap: 6px;
    padding-bottom: 8px;
}

/* ── MESSAGE ── */
.message {
    display: flex; align-items: flex-end; gap: 10px;
    animation: msgIn 0.25s ease both;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message.user { flex-direction: row-reverse; }
.message.oracle { flex-direction: row; }

/* Avatar */
.message-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 12px; font-weight: 700; overflow: hidden;
}
.message-avatar.oracle {
    background: linear-gradient(135deg, #003d7a, #20a898);
    padding: 0; position: relative;
}
/* Oracle avatar — static when showing response */
.message-avatar.oracle img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.oracle-avatar-svg { width: 18px; height: 18px; color: white; }

/* Loading avatar: SVG lotus draw/reconstruct animation */
.message-avatar.oracle.is-loading {
    background: linear-gradient(135deg, #003d7a, #20a898);
}
.oracle-draw-svg {
    width: 100%; height: 100%; padding: 3px;
}
.draw-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawStroke 1.6s ease-in-out infinite alternate;
}
.draw-circle  { animation-delay: 0s;    stroke-dasharray: 120; stroke-dashoffset: 120; }
.draw-p1      { animation-delay: 0.15s; }
.draw-p2      { animation-delay: 0.3s;  }
.draw-p3      { animation-delay: 0.45s; }
.draw-base    { animation-delay: 0.6s;  stroke-dasharray: 60; stroke-dashoffset: 60; }
.draw-dot     { animation-delay: 0.7s;  stroke-dasharray: 12; stroke-dashoffset: 12; }

@keyframes drawStroke {
    0%   { stroke-dashoffset: 200; opacity: 0.3; }
    50%  { stroke-dashoffset: 0;   opacity: 1; }
    100% { stroke-dashoffset: 200; opacity: 0.3; }
}

.message-avatar.user {
    background: linear-gradient(135deg, #374151, #1f2937);
    color: white; letter-spacing: 0.5px;
}
.dark-mode .message-avatar.user { background: linear-gradient(135deg, #4b5563, #374151); }

/* Bubble */
.message-content {
    max-width: min(560px, 85%); padding: 10px 14px;
    border-radius: 18px; font-size: var(--chat-font-size, 15.5px); line-height: 1.8;
    word-break: break-word;
}
.message.oracle .message-content {
    background: transparent;
    border: none;
    border-bottom-left-radius: 6px; color: var(--color-text);
    padding-left: 4px;
    font-size: var(--chat-font-size, 15.5px);
}
.message.user .message-content {
    background: var(--color-user-bubble); color: white;
    border-bottom-right-radius: 6px;
}
.message.user .message-content a { color: rgba(255,255,255,0.85); text-decoration: underline; }
.message.oracle .message-content a { color: var(--color-primary); }

/* Markdown rendering in oracle messages */
.message.oracle .message-content strong { font-weight: 600; }
.message.oracle .message-content em { font-style: italic; }
.message.oracle .message-content code {
    background: rgba(0,0,0,0.06); border-radius: 4px;
    padding: 1px 5px; font-size: 13px; font-family: 'SF Mono', 'Fira Code', monospace;
}
.dark-mode .message.oracle .message-content code { background: rgba(255,255,255,0.08); }
.message.oracle .message-content ul, .message.oracle .message-content ol {
    padding-left: 18px; margin: 6px 0;
}
.message.oracle .message-content li { margin-bottom: 4px; }
.message.oracle .message-content p + p { margin-top: 8px; }

/* Status chip above oracle bubble */
.status-chip {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--color-text-secondary);
    margin-bottom: 6px; margin-left: 40px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--color-primary);
    animation: statusPulse 1s ease-in-out infinite;
}
@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.6); }
}

/* Thinking indicator */
.typing-indicator {
    display: flex; align-items: center; gap: 4px; padding: 2px 0;
}
.typing-indicator span {
    width: 7px; height: 7px; background: var(--color-text-secondary);
    border-radius: 50%; display: inline-block;
    animation: bounce 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* Streaming cursor */
.streaming-cursor {
    display: inline-block; width: 2px; height: 1em;
    background: var(--color-text); vertical-align: middle;
    margin-left: 1px; border-radius: 1px;
    animation: blink 0.8s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── INPUT AREA (bottom shell — populated by JS after first message) ── */
.input-area {
    padding: 8px 20px 12px; background: var(--color-bg);
    border-top: 1px solid var(--color-border); flex-shrink: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    margin-bottom: -4px;
    display: flex; justify-content: center;
}

.input-container { max-width: 740px; width: 100%; margin: 0 auto; }

#errorMessage .error-message {
    background: #fee2e2; color: #dc2626; padding: 8px 12px;
    border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 8px;
    border-left: 3px solid #dc2626;
}
#errorMessage .success-message {
    background: #d1fae5; color: #065f46; padding: 8px 12px;
    border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 8px;
    border-left: 3px solid var(--color-primary);
}

/* File previews */
.image-preview-container, .pdf-preview-container {
    position: relative; display: inline-flex; align-items: center;
    gap: 8px; padding: 8px 12px; background: var(--color-oracle-bubble);
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    margin-bottom: 8px; max-width: 100%;
}
.preview-image { height: 56px; width: 56px; object-fit: cover; border-radius: var(--radius-sm); }
.pdf-icon { width: 24px; height: 24px; color: #dc2626; }
.file-name { font-size: 13px; color: var(--color-text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.remove-file-btn, .remove-preview-btn {
    background: rgba(0,0,0,0.12); border: none; border-radius: 50%;
    width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px; color: var(--color-text); transition: background var(--transition); flex-shrink: 0;
}
.remove-file-btn:hover, .remove-preview-btn:hover { background: rgba(0,0,0,0.25); }

/* Input wrapper */
.input-wrapper {
    display: flex; align-items: flex-end; gap: 6px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 18px; padding: 8px 8px 8px 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.input-wrapper:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(32,168,152,0.15); }

.input-actions { display: flex; align-items: center; gap: 2px; padding-bottom: 4px; }

/* ── + ATTACH POPUP ── */
.attach-popup-wrapper { position: relative; display: flex; align-items: center; }

.attach-plus-btn {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; border-radius: var(--radius-sm);
    color: var(--color-text-secondary); cursor: pointer; transition: all var(--transition);
}
.attach-plus-btn:hover { background: var(--color-hover); color: var(--color-primary); }

.attach-popup {
    display: none; position: absolute; bottom: calc(100% + 10px); left: 0;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 140px; overflow: hidden; z-index: 100;
    animation: popupFadeIn 0.15s ease;
}
.attach-popup.open { display: block; }

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

.attach-option {
    display: flex; align-items: center; gap: 9px;
    width: 100%; padding: 10px 14px; background: none; border: none;
    font-size: 13.5px; font-family: inherit; color: var(--color-text);
    cursor: pointer; transition: background var(--transition); text-align: left;
}
.attach-option:hover { background: var(--color-hover); color: var(--color-primary); }



.message-input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 14.5px; color: var(--color-text); resize: none;
    max-height: 260px; line-height: 1.6; padding: 5px 4px;
    font-family: inherit; min-height: 52px;
}
.message-input::placeholder { color: var(--color-text-secondary); }

.send-btn {
    width: 38px; height: 38px; background: var(--color-primary); border: none;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all var(--transition); color: white; flex-shrink: 0;
}
.send-btn:hover { background: var(--color-primary-dark); transform: scale(1.05); }
.send-btn:active { transform: scale(0.96); }
.send-btn:disabled { background: var(--color-border); cursor: not-allowed; transform: none; }

/* Stop button — shown while AI is generating a response */
.send-btn.stop-mode {
    background: var(--color-text-secondary) !important;
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}
.send-btn.stop-mode:hover {
    background: #374151 !important;
    transform: scale(1.06);
}

.input-footer {
    text-align: center; font-size: 11px; color: var(--color-text-secondary);
    margin-top: 8px; opacity: 0.8;
}

/* ── PDF DOWNLOAD BUTTON ── */
.pdf-download-btn {
    display: inline-flex; align-items: center; gap: 12px;
    background: linear-gradient(135deg, #0a2452 0%, #1a4a8a 50%, #20a898 100%);
    color: white; border: none; border-radius: 12px;
    padding: 12px 20px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; margin-top: 8px; transition: all var(--transition);
    font-family: inherit; text-align: left; min-width: 220px;
    box-shadow: 0 2px 10px rgba(10,36,82,0.25);
    position: relative; overflow: hidden;
}
.pdf-download-btn::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 60%);
    pointer-events: none;
}
.pdf-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(32,168,152,0.45);
    background: linear-gradient(135deg, #0d2d60 0%, #1f56a0 50%, #26c4b0 100%);
}
.pdf-download-btn:active { transform: translateY(0); }
.pdf-download-btn svg { flex-shrink: 0; }

/* ═══════════════════════════════════════════
   AUTH MODAL
═══════════════════════════════════════════ */
.auth-modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
    z-index: 2000; align-items: center; justify-content: center; padding: 16px;
}
.auth-modal.active { display: flex; }

.auth-container {
    background: var(--color-surface); border-radius: var(--radius-xl);
    width: 100%; max-width: 420px; padding: 32px 28px;
    position: relative; box-shadow: 0 24px 60px rgba(0,0,0,0.2);
    animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
    border: 1px solid var(--color-border);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo-header {
    display: flex; flex-direction: column; align-items: center; margin-bottom: 24px; gap: 10px;
}
.auth-logo-header .logo-circle {
    width: 52px; height: 52px; border-radius: 14px;
    background: linear-gradient(135deg, #003d7a, #20a898);
    overflow: hidden; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(32,168,152,0.3);
}
.auth-logo-header .logo-circle img { width: 100%; height: 100%; object-fit: cover; }
.auth-logo-header h3 { font-size: 18px; font-weight: 700; color: var(--color-text); }
.auth-logo-header p { font-size: 13px; color: var(--color-text-secondary); margin-top: -6px; }

.close-modal {
    position: absolute; top: 14px; right: 16px;
    width: 28px; height: 28px; background: var(--color-hover); border: none;
    border-radius: 50%; cursor: pointer; font-size: 18px; display: flex;
    align-items: center; justify-content: center; color: var(--color-text-secondary);
    transition: all var(--transition); line-height: 1;
}
.close-modal:hover { background: var(--color-border); color: var(--color-text); }

.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; background: var(--color-hover); border-radius: var(--radius-sm); padding: 3px; }
.auth-tab {
    flex: 1; padding: 8px; background: none; border: none;
    border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
    cursor: pointer; transition: all var(--transition); color: var(--color-text-secondary); font-family: inherit;
}
.auth-tab.active { background: var(--color-surface); color: var(--color-text); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

.auth-form { display: none; }
.auth-form.active { display: block; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-group input {
    width: 100%; padding: 11px 14px; border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm); font-size: 14px; color: var(--color-text);
    background: var(--color-bg); transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit; outline: none;
}
.form-group input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(32,168,152,0.12); }
.form-group input::placeholder { color: var(--color-text-secondary); font-size: 13.5px; }

.password-input-wrapper { position: relative; }
.password-input-wrapper input { padding-right: 42px; }
.password-toggle {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: var(--color-text-secondary);
    display: flex; align-items: center; justify-content: center; padding: 4px;
    transition: color var(--transition);
}
.password-toggle:hover { color: var(--color-text); }
.eye-icon { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; }

.auth-btn {
    width: 100%; padding: 12px; background: var(--color-primary);
    color: white; border: none; border-radius: var(--radius-sm);
    font-size: 14.5px; font-weight: 600; cursor: pointer;
    transition: all var(--transition); font-family: inherit; margin-top: 4px;
}
.auth-btn:hover { background: var(--color-primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(32,168,152,0.35); }
.auth-btn:active { transform: translateY(0); }

/* Accept Terms */
.accepterms {
    margin: 12px 0 16px; padding: 10px 12px;
    background: var(--color-primary-light); border: 1px solid rgba(32,168,152,0.2);
    border-radius: var(--radius-sm);
}
.accepterms h5 { margin: 0; font-size: 12px; font-weight: 400; color: var(--color-text-secondary); line-height: 1.6; text-align: center; }
.accepterms a { color: var(--color-primary); text-decoration: none; font-weight: 600; }
.accepterms a:hover { text-decoration: underline; }

/* ── LEGAL MODAL ── */
.legal-modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    z-index: 2000; overflow-y: auto; align-items: flex-start; justify-content: center;
    padding: 24px 16px;
}
.legal-modal.active { display: flex; }
.legal-modal-content {
    background: var(--color-surface); border-radius: var(--radius-xl);
    max-width: 800px; width: 100%; position: relative;
    overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: modalIn 0.3s ease both;
}

/* ── COOKIE CONSENT ── */
.cookie-consent {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 16px 20px;
    max-width: 600px; width: calc(100% - 32px);
    z-index: 1500; box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    animation: slideUp 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes slideUp { from { opacity: 0; transform: translateX(-50%) translateY(24px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.cookie-consent.hidden { display: none; }
.cookie-consent-text { flex: 1; min-width: 200px; }
.cookie-consent-text strong { font-size: 14px; }
.cookie-consent-text p { font-size: 12.5px; color: var(--color-text-secondary); margin-top: 4px; line-height: 1.5; }
.cookie-consent-text a { color: var(--color-primary); text-decoration: none; }
.cookie-consent-text a:hover { text-decoration: underline; }
.cookie-consent-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn {
    padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px;
    font-weight: 600; cursor: pointer; transition: all var(--transition); font-family: inherit;
}
.cookie-accept { background: var(--color-primary); color: white; border: none; }
.cookie-accept:hover { background: var(--color-primary-dark); }
.cookie-decline { background: transparent; color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.cookie-decline:hover { background: var(--color-hover); }

/* ── PRIVACY POPUP ── */
.privacy-popup-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px); z-index: 10000;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    animation: fadeIn 0.3s ease;
}
.privacy-popup {
    background: var(--color-surface); border-radius: var(--radius-xl);
    max-width: 680px; width: 100%; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
    border: 1px solid var(--color-border);
}
.privacy-popup-header {
    background: linear-gradient(135deg, #003d7a 0%, #20a898 100%);
    color: white; padding: 28px; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    text-align: center;
}
.privacy-popup-header h2 { font-size: 24px; font-weight: 700; margin: 0 0 6px; color: white; }
.privacy-popup-header p { font-size: 14px; margin: 0; color: rgba(255,255,255,0.9); }
.privacy-popup-content { padding: 24px; }
.privacy-section {
    background: var(--color-oracle-bubble); border-radius: var(--radius-md); padding: 20px;
    margin-bottom: 16px; border: 1px solid var(--color-border);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.privacy-section:hover { border-color: var(--color-primary); box-shadow: 0 4px 12px rgba(32,168,152,0.12); }
.privacy-section h3 { font-size: 16px; font-weight: 700; color: var(--color-text); margin: 0 0 8px; }
.privacy-section p { font-size: 13.5px; line-height: 1.7; color: var(--color-text-secondary); margin: 0 0 12px; }
.privacy-link {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--color-primary); text-decoration: none; font-weight: 600; font-size: 13px;
    padding: 6px 12px; background: var(--color-primary-light);
    border-radius: var(--radius-sm); transition: all var(--transition);
}
.privacy-link:hover { background: var(--color-primary); color: white; }
.privacy-popup-footer { padding: 20px 24px 24px; background: var(--color-hover); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.privacy-notice { font-size: 12.5px; color: var(--color-text-secondary); text-align: center; margin: 0 0 16px; line-height: 1.6; }
.privacy-popup-buttons { display: flex; gap: 10px; justify-content: center; }
.privacy-btn { padding: 12px 28px; border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all var(--transition); font-family: inherit; flex: 1; max-width: 180px; }
.privacy-accept { background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark)); color: white; box-shadow: 0 4px 12px rgba(32,168,152,0.3); }
.privacy-accept:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(32,168,152,0.4); }
.privacy-decline { background: var(--color-surface); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.privacy-decline:hover { background: var(--color-hover); }

/* ── FORGOT PASSWORD LINK ── */
.forgot-password-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 7px;
}
.forgot-password-link {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition);
}
.forgot-password-link:hover { color: var(--color-primary-dark); }


.auth-error-message {
    background: #fee2e2; color: #dc2626; padding: 10px 14px;
    border-radius: var(--radius-sm); margin-bottom: 12px;
    font-size: 13px; border-left: 3px solid #dc2626; animation: fadeInUp 0.2s ease;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — DESKTOP sidebar collapse
═══════════════════════════════════════════ */
@media (min-width: 769px) {
    .sidebar {
        transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), width 0.3s cubic-bezier(0.4,0,0.2,1);
    }
    .app-container.sidebar-collapsed .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
        width: 0;
        min-width: 0;
        overflow: hidden;
        border-right: none;
        pointer-events: none;
    }
    .main-content {
        transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
    }
    /* When collapsed: sidebar slides away, strip (52px) occupies left edge */
    .app-container.sidebar-collapsed .main-content {
        margin-left: 0;
    }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE
═══════════════════════════════════════════ */
@media (max-width: 768px) {
    /* ── Sidebar: always fixed overlay on mobile ── */
    .sidebar {
        position: fixed; left: 0; top: 0;
        width: 280px;
        height: 100vh; height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
        box-shadow: 4px 0 32px rgba(0,0,0,0.18);
        z-index: 200;
    }
    .sidebar.active {
        transform: translateX(0) !important;
        pointer-events: auto !important;
    }
    /* Overlay visible when sidebar open */
    .sidebar-overlay {
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.28s;
        z-index: 199;
    }
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
    /* Collapsed class has no effect on mobile — overlay pattern handles open/close */
    .app-container.sidebar-collapsed .sidebar { transform: translateX(-100%); pointer-events: none; }
    .app-container.sidebar-collapsed .main-content { margin-left: 0 !important; }
    /* Main content always full-width on mobile */
    .main-content { margin-left: 0 !important; width: 100% !important; }
    /* Always show hamburger on mobile */
    .menu-btn { display: flex !important; }
    /* Hide desktop icon strip on mobile */
    .icon-strip { display: none !important; }

    .input-area { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    #bottomInputArea { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .chat-area { padding: 16px 12px; }
    .messages-container { max-width: 100%; }
    .welcome-input-wrap { padding: 0 4px; }
    .suggestion-chips { grid-template-columns: 1fr; }
    .welcome-greeting { font-size: 22px; }
    .auth-container { padding: 24px 20px; }
    .cookie-consent { bottom: 10px; gap: 10px; }
    .cookie-consent-buttons { width: 100%; }
    .cookie-btn { flex: 1; }

    /* Close button always visible inside sidebar on mobile */
    .close-sidebar-btn { display: flex !important; }

    /* Sidebar footer auth / user section always visible */
    .sidebar-footer { display: flex !important; }
}

@media (max-width: 480px) {
    .message-content { max-width: 88%; font-size: 15px; padding: 10px 13px; }
    .welcome-logo-wrap { width: 60px; height: 60px; border-radius: 16px; }
    .welcome-greeting { font-size: 20px; }
    .welcome-sub { font-size: 14px; margin-bottom: 24px; }

    .privacy-popup-buttons { flex-direction: column; }
    .privacy-btn { max-width: 100%; }
}

/* ── DARK MODE TWEAKS ── */
.dark-mode .auth-container { border-color: var(--color-border); }
.dark-mode .input-wrapper { background: var(--color-surface); }
.dark-mode .privacy-section { background: var(--color-hover); }
.dark-mode .cookie-consent { background: #1e1e1e; border-color: var(--color-border); }
.dark-mode .auth-error-message { background: rgba(220,38,38,0.15); }

/* ── ACCESSIBILITY ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Focus visible */
button:focus-visible, input:focus-visible {
    outline: 2px solid var(--color-primary); outline-offset: 2px;
}
/* Textarea: suppress the square outline — glow comes from .input-wrapper:focus-within */
textarea:focus-visible { outline: none; }



/* ══════════════════════════════════════════════════════════
   SIDEBAR RESTRUCTURE — User profile at bottom, dropdown
══════════════════════════════════════════════════════════ */

/* Footer action buttons area */
.footer-actions {
    margin-bottom: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

/* User section — now lives inside sidebar-footer at bottom */
.user-section {
    display: none;
    padding: 10px 0 0 0;
    flex-shrink: 0;
}
.user-section.active { display: block; }

/* Profile card row */
.user-profile-card {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
    border: 1px solid transparent;
}
.user-profile-card:hover {
    background: var(--color-hover);
    border-color: var(--color-border);
}

.user-menu-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
}
.user-menu-btn:hover { background: var(--color-hover); color: var(--color-text); }

/* Dropdown */
.user-dropdown {
    display: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 5px;
    margin-top: 4px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    animation: fadeInUp 0.18s ease both;
}
.user-dropdown.open { display: block; }

/* ══════════════════════════════════════════════════════════
   OTP MODAL STYLES
══════════════════════════════════════════════════════════ */

.auth-modal { display: none; }
.auth-modal.active { display: flex; }

/* OTP method tabs */
.otp-method-tabs {
    display: flex;
    gap: 8px;
    margin: 4px 0 12px;
}
.otp-method-tab {
    flex: 1;
    padding: 9px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all var(--transition);
}
.otp-method-tab.active {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.otp-method-tab:hover:not(.active) { background: var(--color-hover); }

/* 6-digit OTP input row */
.otp-input-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 8px 0 4px;
}
.otp-digit {
    width: 44px;
    height: 52px;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
}
.otp-digit:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(32,168,152,0.15);
}
.otp-digit:not(:placeholder-shown) {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

/* OTP error */
.otp-error-msg {
    color: var(--color-danger);
    font-size: 13px;
    text-align: center;
    margin: 8px 0;
    padding: 10px 14px;
    background: rgba(220,38,38,0.07);
    border-radius: 8px;
    border-left: 3px solid var(--color-danger);
}

/* Resend button */
.resend-otp-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px 8px;
}
.resend-otp-btn:disabled {
    color: var(--color-text-secondary);
    cursor: not-allowed;
    text-decoration: none;
}

@media (max-width: 400px) {
    .otp-digit { width: 38px; height: 46px; font-size: 18px; }
    .otp-input-group { gap: 5px; }
}

/* ═══════════════════════════════════════════
   VERTICAL ICON STRIP
═══════════════════════════════════════════ */
.icon-strip {
    width: 52px;
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    display: none; /* shown when sidebar collapsed on desktop */
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    gap: 2px;
    flex-shrink: 0;
    z-index: 100;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: opacity 0.2s ease;
    order: -1; /* always rendered as the first (leftmost) column */
}
.app-container.sidebar-collapsed .icon-strip {
    display: flex;
}
.strip-btn {
    width: 36px; height: 36px;
    background: none; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.strip-btn svg {
    width: 18px; height: 18px;
    stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.strip-btn:hover { background: var(--color-hover); color: var(--color-text); }
.strip-spacer { flex: 1; }
.strip-avatar {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px; letter-spacing: 0.5px;
    pointer-events: none;
}
.strip-user-btn { padding: 0; }
.strip-user-btn:hover .strip-avatar { box-shadow: 0 0 0 2px var(--color-primary); }

/* Mobile: never show strip */
@media (max-width: 768px) {
    .icon-strip { display: none !important; }
}

/* ═══════════════════════════════════════════
   SETTINGS MODAL
═══════════════════════════════════════════ */
.settings-modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
    z-index: 3000; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}
.settings-modal.active { display: flex; }

.settings-container {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    max-width: 780px; width: 100%;
    max-height: 88vh;
    display: flex; overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,0.28);
    border: 1px solid var(--color-border);
    animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* Settings Sidebar (left nav) */
.settings-sidebar {
    width: 200px; flex-shrink: 0;
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex; flex-direction: column;
    padding: 20px 12px 16px;
    position: relative;
}
.settings-logo-row {
    display: flex; align-items: center; gap: 8px;
    padding: 0 4px 16px; border-bottom: 1px solid var(--color-border);
    margin-bottom: 12px;
}
.settings-logo-icon {
    width: 28px; height: 28px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
    background: linear-gradient(135deg, #003d7a, #20a898);
}
.settings-logo-icon img { width: 100%; height: 100%; object-fit: cover; }
.settings-logo-name { font-size: 13px; font-weight: 600; color: var(--color-text); }

.settings-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.settings-nav-btn {
    width: 100%; padding: 9px 10px;
    background: transparent; border: none; cursor: pointer;
    display: flex; align-items: center; gap: 9px;
    font-size: 13px; font-weight: 500; color: var(--color-text-secondary);
    border-radius: var(--radius-sm); transition: all var(--transition);
    font-family: inherit; text-align: left;
}
.settings-nav-btn svg {
    width: 16px; height: 16px; stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}
.settings-nav-btn:hover { background: var(--color-hover); color: var(--color-text); }
.settings-nav-btn.active {
    background: var(--color-primary-light); color: var(--color-primary);
    font-weight: 600;
}
.settings-close-btn {
    margin-top: 12px; width: 32px; height: 32px;
    background: none; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); color: var(--color-text-secondary);
    transition: all var(--transition); align-self: flex-end;
}
.settings-close-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.settings-close-btn:hover { background: var(--color-hover); color: var(--color-text); }

/* Settings Content (right panel) */
.settings-content {
    flex: 1; overflow-y: auto; padding: 24px 28px;
    min-width: 0;
}
.settings-tab { display: none; }
.settings-tab.active { display: block; }

.settings-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}
.settings-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.settings-section-title {
    font-size: 15px; font-weight: 700; color: var(--color-text);
    margin-bottom: 5px;
}
.settings-section-desc {
    font-size: 13px; color: var(--color-text-secondary);
    line-height: 1.6; margin-bottom: 14px;
}

/* Account Profile Header */
.account-profile-header {
    display: flex; align-items: center; gap: 16px;
    padding: 16px; background: var(--color-hover);
    border-radius: var(--radius-md); margin-bottom: 0;
}
.account-avatar-lg {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.account-name { font-size: 17px; font-weight: 700; color: var(--color-text); }
.account-email { font-size: 13px; color: var(--color-text-secondary); margin: 2px 0 6px; }
.account-badge { font-size: 12px; color: var(--color-primary); font-weight: 600; }

.settings-guest-notice {
    display: flex; align-items: center; gap: 14px;
    padding: 16px; background: var(--color-hover); border-radius: var(--radius-md);
    border: 1px dashed var(--color-border);
}
.guest-icon { font-size: 32px; flex-shrink: 0; }
.settings-guest-notice strong { font-size: 14px; color: var(--color-text); display: block; margin-bottom: 3px; }
.settings-guest-notice p { font-size: 13px; color: var(--color-text-secondary); margin: 0; }

/* Input field */
.settings-input {
    flex: 1; padding: 10px 14px; border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm); font-size: 13.5px; color: var(--color-text);
    background: var(--color-bg); font-family: inherit; outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.settings-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(32,168,152,0.12); }
.settings-field-row { display: flex; gap: 10px; align-items: center; }

/* Action buttons */
.settings-action-btn {
    padding: 9px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; cursor: pointer;
    border: 1px solid var(--color-border); background: var(--color-surface);
    color: var(--color-text); font-family: inherit;
    transition: all var(--transition); display: inline-flex; align-items: center; gap: 6px;
    white-space: nowrap; flex-shrink: 0;
}
.settings-action-btn:hover { background: var(--color-hover); }
.settings-action-btn.primary {
    background: var(--color-primary); color: white; border-color: var(--color-primary);
}
.settings-action-btn.primary:hover { background: var(--color-primary-dark); }
.settings-action-btn.danger {
    background: transparent; color: var(--color-danger); border-color: rgba(220,38,38,0.25);
}
.settings-action-btn.danger:hover { background: rgba(220,38,38,0.08); border-color: var(--color-danger); }

/* Action list rows */
.settings-action-list { display: flex; flex-direction: column; gap: 2px; }
.settings-action-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-radius: var(--radius-md); gap: 16px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    margin-bottom: 6px;
}
.settings-action-row:last-child { margin-bottom: 0; }
.danger-row { border-color: rgba(220,38,38,0.15); background: rgba(220,38,38,0.03); }
.settings-action-label { font-size: 13.5px; font-weight: 600; color: var(--color-text); margin-bottom: 2px; }
.danger-text { color: var(--color-danger); }
.settings-action-desc { font-size: 12px; color: var(--color-text-secondary); }

/* Toggle row */
.settings-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-radius: var(--radius-md); gap: 16px;
    border: 1px solid var(--color-border); margin-bottom: 6px;
}
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--color-border); border-radius: 24px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; bottom: 3px; background: white; border-radius: 50%;
    transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Theme picker */
.settings-theme-grid { display: flex; gap: 14px; }
.theme-option {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    background: none; border: 2px solid var(--color-border);
    border-radius: var(--radius-md); padding: 10px 16px;
    cursor: pointer; font-family: inherit; font-size: 13px;
    color: var(--color-text-secondary); transition: all var(--transition);
}
.theme-option:hover, .theme-option.active { border-color: var(--color-primary); color: var(--color-primary); }
.theme-preview {
    width: 80px; height: 50px; border-radius: 6px; display: flex; overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}
.theme-preview-light { background: #fff; }
.theme-preview-light .theme-preview-sidebar { width: 28px; background: #f5f5f0; border-right: 1px solid #e5e5e0; }
.theme-preview-light .theme-preview-main { flex: 1; background: #fff; }
.theme-preview-dark { background: #1a1a1a; }
.theme-preview-dark .theme-preview-sidebar { width: 28px; background: #111; border-right: 1px solid #2e2e2e; }
.theme-preview-dark .theme-preview-main { flex: 1; background: #1a1a1a; }

/* Font size buttons */
.settings-font-btns { display: flex; gap: 10px; align-items: flex-end; }
.font-size-btn {
    width: 40px; height: 40px; background: var(--color-surface);
    border: 1.5px solid var(--color-border); border-radius: var(--radius-sm);
    cursor: pointer; font-family: inherit; color: var(--color-text-secondary);
    transition: all var(--transition); font-size: 14px; font-weight: 600;
}
.font-size-btn:hover, .font-size-btn-active { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-light); }
.font-size-btn-active { font-size: 14px; }
.font-size-lg { font-size: 20px; height: 48px; }

/* About header */
.about-header {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 16px 0 20px;
}
.about-logo {
    width: 64px; height: 64px; border-radius: 18px; overflow: hidden;
    background: linear-gradient(135deg, #003d7a, #20a898);
    box-shadow: 0 8px 24px rgba(32,168,152,0.3); margin-bottom: 4px;
}
.about-logo img { width: 100%; height: 100%; object-fit: cover; }
.about-title { font-size: 20px; font-weight: 700; color: var(--color-text); }
.about-version { font-size: 12px; color: var(--color-primary); font-weight: 600; }
.about-authors { font-size: 12.5px; color: var(--color-text-secondary); }

/* Link rows */
.settings-link-row {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: var(--radius-md);
    text-decoration: none; color: var(--color-text);
    border: 1px solid var(--color-border); margin-bottom: 6px;
    font-size: 13.5px; font-weight: 500; transition: all var(--transition);
    background: var(--color-surface);
}
.settings-link-row svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; color: var(--color-text-secondary); }
.settings-link-row .link-arrow { margin-left: auto; color: var(--color-text-secondary); }
.settings-link-row:hover { background: var(--color-hover); border-color: var(--color-primary); color: var(--color-primary); }
.settings-link-row:last-child { margin-bottom: 0; }

/* Settings responsive */
@media (max-width: 580px) {
    .settings-container { flex-direction: column; max-height: 95vh; }
    .settings-sidebar { width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px; border-right: none; border-bottom: 1px solid var(--color-border); }
    .settings-logo-row { flex: 0 0 100%; border-bottom: none; padding-bottom: 8px; margin-bottom: 8px; }
    .settings-nav { flex-direction: row; gap: 4px; flex: 1; }
    .settings-nav-btn { padding: 7px 8px; font-size: 11px; flex-direction: column; gap: 4px; text-align: center; justify-content: center; }
    .settings-nav-btn svg { width: 14px; height: 14px; }
    .settings-close-btn { align-self: flex-start; margin-top: 0; }
    .settings-content { padding: 16px; }
}
/* ── SHARE BUTTON & POPUP ──────────────────────────────── */
.share-btn-wrap {
    position: relative;
}
.share-btn {
    color: var(--text-secondary, #6b7280);
    transition: color 0.2s;
}
.share-btn:hover {
    color: var(--accent, #2da58e);
}
.share-popup {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 14px 16px;
    min-width: 260px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.13);
    z-index: 999;
    animation: sharePopIn 0.18s ease;
}
.share-popup.visible {
    display: block;
}
@keyframes sharePopIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.share-popup-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary, #111);
}
.share-popup-url {
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
    background: var(--surface-secondary, #f3f4f6);
    border-radius: 7px;
    padding: 7px 10px;
    word-break: break-all;
    margin-bottom: 8px;
    font-family: monospace;
}
.share-popup-hint {
    font-size: 11px;
    color: var(--text-secondary, #9ca3af);
}

/* ── ORACLE MESSAGE BODY (wraps content + copy footer) ── */
.oracle-msg-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.oracle-msg-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 0;
    margin-top: 2px;
}

/* ── COPY BUTTON ON AI MESSAGES ───────────────────────── */
.message.oracle {
    position: relative;
}
.copy-msg-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px 7px;
    border-radius: 6px;
    opacity: 1;
    transition: opacity 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    color: var(--color-text-secondary, #9ca3af);
    margin-top: 4px;
    flex-shrink: 0;
    align-self: flex-end;
}
.copy-msg-btn:hover {
    background: var(--color-hover, #f3f4f6);
    color: var(--color-primary, #20a898);
}
.copy-msg-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.copy-msg-btn.copied svg {
    stroke: #22c55e;
}
.dark-mode .copy-msg-btn:hover {
    background: var(--color-hover);
}

/* ═══════════════════════════════════════════
   VOICE BUTTON — dynamic send/mic toggle
═══════════════════════════════════════════ */
.send-btn.voice-mode,
.send-btn.send-mode {
    background: var(--color-primary);
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.send-btn.voice-mode:hover,
.send-btn.send-mode:hover {
    background: var(--color-primary-dark);
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(32,168,152,0.4);
}
/* Both icons sit centered inside the button */
#sendIcon, #micIcon {
    position: absolute;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
#sendBtn {
    position: relative;
    overflow: visible;
}

/* ═══════════════════════════════════════════
   VOICE CHAT MODAL
═══════════════════════════════════════════ */
.voice-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3000;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}
.voice-modal.active {
    display: flex;
}
.voice-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.voice-modal-card {
    position: relative;
    background: var(--color-surface);
    border-radius: 28px 28px 0 0;
    width: 100%;
    max-width: 480px;
    padding: 28px 24px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    box-shadow: 0 -8px 48px rgba(0,0,0,0.22);
    animation: voiceSlideUp 0.38s cubic-bezier(0.34,1.2,0.64,1) both;
    border: 1px solid var(--color-border);
    border-bottom: none;
}
@keyframes voiceSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Header */
.voice-modal-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.voice-modal-logo {
    width: 42px; height: 42px;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg,#003d7a,#20a898);
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(32,168,152,0.28);
}
.voice-modal-logo img { width:100%; height:100%; object-fit:cover; }
.voice-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}
.voice-modal-subtitle {
    font-size: 12.5px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}
.voice-close-btn {
    margin-left: auto;
    width: 32px; height: 32px;
    background: var(--color-hover);
    border: none; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.voice-close-btn:hover { background: var(--color-border); color: var(--color-text); }

/* Wave area */
.voice-wave-area {
    width: 100%;
    height: 110px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
#voiceWaveCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.4s;
    border-radius: 12px;
}
#voiceWaveCanvas.active { opacity: 1; }

/* Idle rings */
.voice-wave-idle {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}
.voice-wave-idle.hidden { opacity: 0; pointer-events: none; }
.idle-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    opacity: 0.18;
    animation: idlePulse 2.4s ease-in-out infinite;
}
.ring1 { width: 90px; height: 90px; animation-delay: 0s; }
.ring2 { width: 65px; height: 65px; animation-delay: 0.4s; opacity: 0.28; }
.ring3 { width: 44px; height: 44px; animation-delay: 0.8s; opacity: 0.4; }
@keyframes idlePulse {
    0%,100% { transform: scale(1); opacity: 0.18; }
    50%      { transform: scale(1.08); opacity: 0.35; }
}
.idle-mic-icon {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Transcript */
.voice-transcript-wrap {
    width: 100%;
    min-height: 60px;
    background: var(--color-oracle-bubble);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 24px;
}
.voice-transcript {
    font-size: 14.5px;
    color: var(--color-text);
    line-height: 1.6;
    text-align: center;
    min-height: 22px;
    font-style: italic;
    color: var(--color-text-secondary);
    transition: color 0.3s;
}
.voice-transcript.has-text {
    font-style: normal;
    color: var(--color-text);
}

/* Controls */
.voice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.voice-mic-btn {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--color-primary);
    border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.2s cubic-bezier(0.34,1.4,0.64,1);
    box-shadow: 0 6px 24px rgba(32,168,152,0.4);
    position: relative;
}
.voice-mic-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 32px rgba(32,168,152,0.55);
}
.voice-mic-btn:active { transform: scale(0.95); }
.voice-mic-btn.recording {
    background: #ef4444;
    box-shadow: 0 6px 24px rgba(239,68,68,0.5);
    animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
    0%,100% { box-shadow: 0 6px 24px rgba(239,68,68,0.5); }
    50%      { box-shadow: 0 6px 36px rgba(239,68,68,0.8), 0 0 0 14px rgba(239,68,68,0.12); }
}
.voice-mic-btn.processing {
    background: var(--color-primary-dark);
    animation: none;
    opacity: 0.8;
    cursor: not-allowed;
}
.voice-mic-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    text-align: center;
}
/* Stop button — always visible, lets user end the session */
.voice-stop-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border-radius: 20px;
    border: 1.5px solid var(--color-danger, #ef4444);
    background: transparent;
    color: var(--color-danger, #ef4444);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    margin-top: 2px;
}
.voice-stop-btn:hover {
    background: var(--color-danger, #ef4444);
    color: #fff;
}

/* Speaking bar */
.voice-speaking-bar {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 8px 16px;
    background: var(--color-primary-light);
    border-radius: 20px;
    margin-top: 4px;
}
.speaking-dot {
    width: 5px; height: 18px;
    background: var(--color-primary);
    border-radius: 3px;
    animation: speakBar 0.8s ease-in-out infinite;
}
.speaking-dot:nth-child(1) { animation-delay: 0s;    height: 8px; }
.speaking-dot:nth-child(2) { animation-delay: 0.1s;  height: 18px; }
.speaking-dot:nth-child(3) { animation-delay: 0.2s;  height: 12px; }
.speaking-dot:nth-child(4) { animation-delay: 0.3s;  height: 20px; }
.speaking-dot:nth-child(5) { animation-delay: 0.15s; height: 10px; }
@keyframes speakBar {
    0%,100% { transform: scaleY(0.5); opacity: 0.6; }
    50%      { transform: scaleY(1.4); opacity: 1; }
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .voice-modal-card { border-radius: 22px 22px 0 0; padding: 22px 18px 32px; }
    .voice-wave-area { height: 90px; }
}

/* ══════════════════════════════════════════════════════════════
   NEW SPLIT AUTH PANEL
══════════════════════════════════════════════════════════════ */

.auth-container-wide {
    max-width: 820px !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.auth-split-panel {
    display: flex;
    min-height: 520px;
}

/* LEFT branding side */
.auth-brand-side {
    width: 320px;
    flex-shrink: 0;
    background: linear-gradient(150deg, #003d7a 0%, #20a898 100%);
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-brand-glow {
    position: absolute;
    width: 300px; height: 300px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    top: -80px; right: -80px;
    pointer-events: none;
}

.auth-brand-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.auth-brand-logo {
    width: 72px; height: 72px;
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(4px);
    margin-bottom: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.2);
}
.auth-brand-logo img { width: 100%; height: 100%; object-fit: cover; }

.auth-brand-title {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
    letter-spacing: -0.4px;
}
.auth-brand-sub {
    font-size: 13px;
    color: rgba(255,255,255,0.75);
    margin-bottom: 28px;
    line-height: 1.5;
}

.auth-brand-features {
    display: flex;
    flex-direction: column;
    gap: 11px;
    width: 100%;
}
.auth-feat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: rgba(255,255,255,0.88);
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 9px 14px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.15);
}
.auth-feat-icon { font-size: 16px; }

/* RIGHT form side */
.auth-form-side {
    flex: 1;
    padding: 36px 32px 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Tabs */
.auth-tabs {
    display: flex;
    gap: 0;
    background: var(--color-hover);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 22px;
}
.auth-tab {
    flex: 1;
    padding: 9px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.auth-tab.active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Google button */
.google-auth-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 11px 18px;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    font-family: inherit;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.google-auth-btn:hover {
    background: var(--color-hover);
    border-color: var(--color-text-secondary);
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    color: var(--color-text-secondary);
    font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* Switch text */
.auth-switch-text {
    text-align: center;
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 14px;
}
.auth-switch-text button {
    background: none;
    border: none;
    color: var(--color-primary);
    font-weight: 600;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
}
.auth-switch-text button:hover { text-decoration: underline; }

/* ── CLOSE button on the wide auth modal ── */
.auth-container-wide .close-modal {
    position: absolute;
    top: 12px; right: 14px;
    z-index: 10;
    background: var(--color-hover);
    border: none;
    border-radius: 50%;
    width: 30px; height: 30px;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--color-text-secondary);
    transition: background 0.18s;
}
.auth-container-wide .close-modal:hover { background: var(--color-border); }

/* Responsive: stack on mobile */
@media (max-width: 660px) {
    .auth-split-panel { flex-direction: column; }
    .auth-brand-side { width: 100%; padding: 24px 20px; min-height: auto; }
    .auth-brand-features { display: none; }
    .auth-form-side { padding: 24px 20px; }
    .auth-container-wide { max-width: 420px !important; }
}

/* ══════════════════════════════════════════════════════════════
   TOKEN LIMIT POPUP
══════════════════════════════════════════════════════════════ */

.token-limit-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.token-limit-overlay.active { display: flex; }

.token-limit-modal {
    background: var(--color-surface);
    border-radius: 24px;
    padding: 40px 36px;
    max-width: 680px;
    width: 100%;
    text-align: center;
    box-shadow: 0 32px 80px rgba(0,0,0,0.35);
    border: 1px solid var(--color-border);
    animation: tokenModalIn 0.38s cubic-bezier(0.34,1.3,0.64,1) both;
}
@keyframes tokenModalIn {
    from { opacity: 0; transform: scale(0.88) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.token-limit-icon {
    font-size: 52px;
    margin-bottom: 12px;
    line-height: 1;
    display: block;
}
.token-limit-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 10px;
}
.token-limit-desc {
    font-size: 15px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: 28px;
}
.token-timer-badge {
    display: inline-block;
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 14px;
    border: 1px solid rgba(32,168,152,0.3);
}

.token-limit-plans {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    justify-content: center;
}

.token-plan-card {
    flex: 1;
    max-width: 260px;
    border: 1.5px solid var(--color-border);
    border-radius: 16px;
    padding: 22px 18px;
    text-align: left;
    position: relative;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.token-plan-card:hover {
    box-shadow: 0 8px 28px rgba(0,0,0,0.1);
}
.token-plan-card.token-plan-featured {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(32,168,152,0.15);
}
.token-plan-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    white-space: nowrap;
}
.token-plan-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}
.token-plan-price {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 14px;
}
.token-plan-price span {
    font-size: 13px;
    color: var(--color-text-secondary);
    font-weight: 400;
}
.token-plan-perks {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
    font-size: 13px;
    color: var(--color-text-secondary);
}
.token-plan-btn {
    width: 100%;
    padding: 11px;
    border-radius: 10px;
    border: 1.5px solid var(--color-border);
    background: transparent;
    color: var(--color-text);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    font-family: inherit;
}
.token-plan-btn:hover { background: var(--color-hover); }
.token-plan-btn-primary {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}
.token-plan-btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }

.token-limit-wait {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

@media (max-width: 520px) {
    .token-limit-plans { flex-direction: column; align-items: center; }
    .token-plan-card { max-width: 100%; width: 100%; }
    .token-limit-modal { padding: 30px 18px; }
}

/* ── Premium Badge ───────────────────────────────────────── */
.premium-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    margin-top: 2px;
    letter-spacing: 0.3px;
    line-height: 1.6;
}
.badge-pro {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    box-shadow: 0 1px 4px rgba(245,158,11,0.4);
}
.badge-basic {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 1px 4px rgba(99,102,241,0.4);
}

/* ── Premium Avatar Ring ──────────────────────────────────── */
.user-avatar.premium-avatar {
    outline: 2.5px solid #f59e0b;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(245,158,11,0.15);
}

/* ── Razorpay secure note ──────────────────────────────────── */
.token-secure-note {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--color-text-secondary);
    background: var(--color-hover);
    border-radius: 8px;
    padding: 6px 12px;
    margin: 10px 0 4px;
    gap: 2px;
}

/* ── Plan card shimmer on featured ──────────────────────────── */
.token-plan-card.token-plan-featured {
    animation: planPulse 3s ease-in-out infinite;
}
@keyframes planPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(32,168,152,0.0), 0 4px 20px rgba(32,168,152,0.15); }
    50%       { box-shadow: 0 0 0 4px rgba(32,168,152,0.12), 0 4px 20px rgba(32,168,152,0.25); }
}

/* ── Token limit modal max-height scroll on small screens ─── */
.token-limit-modal {
    max-height: 92vh;
    overflow-y: auto;
}

/* ══════════════════════════════════════════════════════════
   UPGRADE BUTTON IN USER DROPDOWN
   ══════════════════════════════════════════════════════════ */
.user-action-btn.upgrade-btn {
    background: linear-gradient(135deg, #003d7a 0%, #20a898 100%);
    color: #fff !important;
    font-weight: 700;
    border-radius: 10px;
    margin-bottom: 6px;
    border: none;
    box-shadow: 0 2px 10px rgba(32,168,152,0.25);
    transition: box-shadow 0.2s, transform 0.15s;
    letter-spacing: 0.01em;
}
.user-action-btn.upgrade-btn:hover {
    box-shadow: 0 4px 18px rgba(32,168,152,0.38);
    transform: translateY(-1px);
}
.user-action-btn.upgrade-btn svg {
    stroke: #fff;
}

/* ══════════════════════════════════════════════════════════
   PRICING MODAL
   ══════════════════════════════════════════════════════════ */
.pricing-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(6px);
    z-index: 10500;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.pricing-modal-overlay.active {
    display: flex;
    animation: fadeInOverlay 0.25s ease;
}
@keyframes fadeInOverlay {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.pricing-modal-box {
    background: var(--color-surface, #fff);
    border-radius: 20px;
    max-width: 620px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px 28px 28px;
    position: relative;
    box-shadow: 0 24px 80px rgba(0,0,0,0.32);
    animation: slideUpModal 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes slideUpModal {
    from { opacity: 0; transform: translateY(32px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.pricing-close-btn {
    position: absolute;
    top: 14px; right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-secondary, #888);
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.pricing-close-btn:hover {
    background: var(--color-border, #eee);
    color: var(--color-text, #111);
}
.pricing-header {
    text-align: center;
    margin-bottom: 24px;
}
.pricing-logo {
    font-size: 36px;
    margin-bottom: 8px;
}
.pricing-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text, #111);
    margin: 0 0 6px;
}
.pricing-subtitle {
    font-size: 0.9rem;
    color: var(--color-text-secondary, #888);
    margin: 0 0 12px;
}
.pricing-free-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-bg, #f5f5f5);
    border: 1px solid var(--color-border, #ddd);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.82rem;
    color: var(--color-text-secondary, #666);
}
.pricing-free-badge {
    background: var(--color-text-secondary, #888);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    letter-spacing: 0.05em;
}
.pricing-plans-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}
@media (max-width: 500px) {
    .pricing-plans-grid { grid-template-columns: 1fr; }
}
.pricing-card {
    border: 1.5px solid var(--color-border, #ddd);
    border-radius: 16px;
    padding: 20px;
    position: relative;
    background: var(--color-surface, #fff);
    transition: transform 0.18s, box-shadow 0.18s;
}
.pricing-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(0,0,0,0.1);
}
.pricing-card-featured {
    border-color: #20a898;
    background: linear-gradient(160deg, rgba(32,168,152,0.05) 0%, rgba(0,61,122,0.04) 100%);
    box-shadow: 0 4px 20px rgba(32,168,152,0.15);
}
.pricing-popular-tag {
    position: absolute;
    top: -11px; left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #003d7a, #20a898);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 14px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.03em;
}
.pricing-card-header {
    text-align: center;
    margin-bottom: 14px;
}
.pricing-plan-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 4px;
}
.pricing-plan-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-text, #111);
}
.pricing-plan-price {
    font-size: 2rem;
    font-weight: 900;
    color: var(--color-primary, #20a898);
    line-height: 1.1;
    margin-top: 4px;
}
.pricing-plan-price span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary, #888);
}
.pricing-perks {
    list-style: none;
    padding: 0; margin: 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.pricing-perks li {
    font-size: 0.84rem;
    color: var(--color-text, #333);
    display: flex;
    align-items: center;
    gap: 6px;
}
.perk-x { opacity: 0.45; }
.pricing-cta-btn {
    width: 100%;
    padding: 11px 0;
    border: none;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}
.pricing-cta-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.pricing-cta-basic {
    background: var(--color-border, #eee);
    color: var(--color-text, #111);
    border: 1.5px solid var(--color-border, #ccc);
}
.pricing-cta-pro {
    background: linear-gradient(135deg, #003d7a 0%, #20a898 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(32,168,152,0.3);
}
.pricing-secure-row {
    text-align: center;
    font-size: 0.78rem;
    color: var(--color-text-secondary, #999);
    margin-bottom: 6px;
}
.pricing-hindi-note {
    text-align: center;
    font-size: 0.78rem;
    color: var(--color-text-secondary, #aaa);
    margin: 0;
}

/* dark mode pricing */
body.dark-mode .pricing-modal-box {
    background: #1a1f2e;
    border: 1px solid rgba(255,255,255,0.08);
}
body.dark-mode .pricing-card {
    background: #232838;
    border-color: rgba(255,255,255,0.1);
}
body.dark-mode .pricing-card-featured {
    border-color: #20a898;
    background: linear-gradient(160deg, rgba(32,168,152,0.08), rgba(0,61,122,0.06));
}
body.dark-mode .pricing-free-note {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.12);
}
body.dark-mode .pricing-cta-basic {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
    color: #e8eaf0;
}

/* ══════════════════════════════════════════════════════════
   AI THOUGHT TRAIL
   ══════════════════════════════════════════════════════════ */
.thought-trail-wrap {
    margin-top: 10px;
    border-top: 1px solid var(--color-border, rgba(0,0,0,0.08));
    padding-top: 8px;
}
.thought-trail-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--color-text-secondary, #888);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 3px 6px 3px 2px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    letter-spacing: 0.01em;
}
.thought-trail-toggle:hover {
    background: var(--color-bg, #f0f4f8);
    color: var(--color-primary, #20a898);
}
.trail-toggle-label {
    opacity: 0.75;
}
.thought-trail-toggle:hover .trail-toggle-label { opacity: 1; }
.trail-arrow { flex-shrink: 0; }
.thought-trail-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 10px 4px 4px;
}
.trail-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
    padding-bottom: 10px;
}
.trail-step:last-child { padding-bottom: 0; }
.trail-step:last-child .trail-step-connector { display: none; }
.trail-step-icon {
    font-size: 15px;
    width: 26px;
    height: 26px;
    background: var(--color-bg, #f5f7fa);
    border: 1.5px solid var(--color-border, #e0e4ea);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.trail-step-body {
    flex: 1;
    padding-top: 3px;
}
.trail-step-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text, #333);
    line-height: 1.2;
}
.trail-step-detail {
    font-size: 0.75rem;
    color: var(--color-text-secondary, #999);
    margin-top: 1px;
    line-height: 1.3;
}
.trail-step-connector {
    position: absolute;
    left: 12px;
    top: 26px;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--color-border, #dde1e8) 0%, transparent 100%);
    border-radius: 2px;
}

/* dark mode trail */
body.dark-mode .thought-trail-wrap {
    border-top-color: rgba(255,255,255,0.08);
}
body.dark-mode .thought-trail-toggle:hover {
    background: rgba(255,255,255,0.05);
}
body.dark-mode .trail-step-icon {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
}
body.dark-mode .trail-step-connector {
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%);
}
body.dark-mode .trail-step-label { color: #d8dce8; }
body.dark-mode .trail-step-detail { color: #7a8299; }

