*,
::before,
::after {
    box-sizing: border-box;
}

/* ── Mobile viewport fix ── */
html, body {
    height: 100%;
    height: 100dvh;
}

.app-shell {
    height: 100vh;
    height: 100dvh;
    height: var(--vh, 100dvh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
}

@supports (height: 100dvh) {
    .app-shell { height: 100dvh; }
}

/* ── Smooth scrolling ── */
#chat-messages {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* ── Thinking bubble ── */
#thinking-bubble {
    animation: fadeIn 0.3s ease-out;
}

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

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

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

@keyframes blob {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -50px) scale(1.1); }
    50% { transform: translate(-20px, 20px) scale(0.9); }
    75% { transform: translate(20px, 30px) scale(1.05); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

@keyframes pulse-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-slideUp {
    animation: slideUp 0.5s ease-out;
}

.animate-fadeIn {
    animation: fadeIn 0.5s ease-out;
}

.animate-blob {
    animation: blob 7s ease-in-out infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

/* ── Chat message entrance ── */
#query-response > * {
    animation: fadeIn 0.35s ease-out;
}

.chat-msg-user {
    animation: slideInRight 0.3s ease-out;
}

.chat-msg-ai {
    animation: slideInLeft 0.3s ease-out;
}

/* ── Typing dots ── */
.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: currentColor;
    animation: pulse-dot 1.4s ease-in-out infinite;
}

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

/* ── Glass card ── */
.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ═══════════════════════════════════════════════
   PROSE — AI Markdown Rendering
   Beautiful structured rendering for Atlas responses
   ═══════════════════════════════════════════════ */

.prose {
    line-height: 1.8;
    color: #334155;
    font-size: 0.875rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ── Headings ── */
.prose h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    margin-top: 0;
    margin-bottom: 0.25rem;
    letter-spacing: -0.025em;
    line-height: 1.3;
}

.prose h2 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #1e3a5f;
    margin-top: 1.5rem;
    margin-bottom: 0.625rem;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, #f0f7ff, #eef2ff);
    border-left: 3px solid #3b82f6;
    border-radius: 0 0.5rem 0.5rem 0;
    letter-spacing: 0.01em;
}

.prose h2:first-child,
.prose h1 + h2,
.prose h1 + p + h2 {
    margin-top: 0.75rem;
}

.prose h3 {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #1e3a5f;
    margin-top: 1.25rem;
    margin-bottom: 0.375rem;
    letter-spacing: 0.01em;
}

/* ── Summary subtitle ── */
.prose h1 + p {
    color: #64748b;
    font-size: 0.8125rem;
    margin-top: 0;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

/* ── Paragraphs ── */
.prose p {
    margin: 0.5rem 0;
    line-height: 1.75;
}

.prose > p:first-child {
    margin-top: 0;
}

.prose > p:last-child {
    margin-bottom: 0;
}

/* ── Strong / Emphasis ── */
.prose strong {
    font-weight: 700;
    color: #0f172a;
}

.prose em {
    font-style: italic;
    color: #475569;
}

/* ── Lists ── */
.prose ul,
.prose ol {
    padding-inline-start: 0;
    margin: 0.75rem 0;
    list-style: none;
}

.prose li {
    margin: 0.25rem 0;
    line-height: 1.65;
    padding: 0.375rem 0.625rem 0.375rem 1.75rem;
    position: relative;
    border-radius: 0.375rem;
    transition: background 0.15s ease;
}

.prose li:hover {
    background: #f8fafc;
}

.prose ul > li::before {
    content: '';
    position: absolute;
    left: 0.625rem;
    top: 0.875rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1e3a5f);
}

.prose ol {
    counter-reset: ol-counter;
}

.prose ol > li {
    counter-increment: ol-counter;
}

.prose ol > li::before {
    content: counter(ol-counter);
    position: absolute;
    left: 0.375rem;
    top: 0.375rem;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1e3a5f;
    font-size: 0.6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prose li > strong:first-child {
    color: #1e3a5f;
}

/* ── Tables — the main attraction ── */
.prose .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.02);
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    margin: 0;
    font-size: 0.8125rem;
}

/* When table has no wrapper div */
.prose > table {
    margin: 1rem 0;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.02);
}

.prose thead {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.prose th {
    padding: 0.625rem 0.875rem;
    text-align: start;
    font-weight: 700;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #1e3a5f;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.prose td {
    padding: 0.5rem 0.875rem;
    text-align: start;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.prose tbody tr:last-child td {
    border-bottom: none;
}

.prose tbody tr {
    transition: background 0.15s ease;
}

.prose tbody tr:nth-child(even) {
    background: #fafbfd;
}

.prose tbody tr:hover {
    background: #eff6ff;
}

/* Numeric cells alignment */
.prose td:last-child,
.prose th:last-child {
    text-align: end;
}

/* ── Metric highlights ── */
.prose p > strong:only-child {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: linear-gradient(135deg, #eff6ff, #e0f2fe);
    border-radius: 0.375rem;
    color: #1e3a5f;
    font-size: 0.8125rem;
}

/* ── Code ── */
.prose code {
    background-color: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.375rem;
    font-size: 0.8em;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    color: #1e3a5f;
}

.prose pre {
    background-color: #1f2937;
    color: #e5e7eb;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.8125rem;
    line-height: 1.7;
    border: 1px solid #374151;
}

.prose pre code {
    background-color: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
    border-radius: 0;
}

/* ── Blockquotes — key takeaways ── */
.prose blockquote {
    border-inline-start: 3px solid #3b82f6;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f4fa 100%);
    border-radius: 0 0.625rem 0.625rem 0;
    color: #1e3a5f;
    font-style: normal;
    font-size: 0.8125rem;
    font-weight: 500;
}

.prose blockquote p {
    margin: 0;
}

.prose blockquote strong {
    color: #1e3a5f;
}

/* ── Links ── */
.prose a {
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.prose a:hover {
    color: #1d4ed8;
}

/* ── Horizontal Rule — section divider ── */
.prose hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, #cbd5e1, transparent);
    margin: 1.5rem 0;
}

/* ── Atlas response container ── */
.atlas-response {
    transition: box-shadow 0.2s ease;
}

.atlas-response:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Section dividers between h2 blocks */
.prose h2 ~ h2 {
    margin-top: 1.25rem;
    padding-top: 0;
}

/* ── Quick prompt buttons ── */
.quick-prompt {
    transition: all 0.2s ease;
}

.quick-prompt:hover {
    transform: translateY(-1px);
}

.quick-prompt:active {
    transform: translateY(0);
}

/* ── Scrollbar ── */
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 9999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ── Focus ring utility ── */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.3);
}
