/* Legal Advisory System v8.0 - Modern UI */

:root {
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --accent: #4f6ef7;
    --accent-hover: #3b5de7;
    --accent-subtle: #eef1fe;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --success-text: #065f46;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-text: #92400e;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-text: #991b1b;
    --bg: #f8f9fb;
    --bg-chat: #ffffff;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 10px;
    --radius-lg: 14px;
    --sidebar-width: 280px;
    --mobile-header-height: 56px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* ===================== APP SHELL ===================== */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* Invert the logo on dark-background containers so the black silhouette
   reads as a white silhouette against the dark navy background. The logo
   is a black wordmark on a white square; without inversion it's invisible
   inside .sidebar / .guided-header / .mobile-header. */
.sidebar .brand-icon img,
.guided-header-brand img,
.mobile-brand-icon {
    filter: invert(1);
}

/* ============ Clerk auth gate ============
   The gate is a full-screen overlay shown until Clerk is loaded and
   the user is signed in. CSS toggles via body classes set by clerk.js:
     .clerk-loading    — SDK still booting (gate visible, app hidden)
     .clerk-signed-out — SDK ready, no user (gate visible, app hidden)
     .clerk-signed-in  — user authed (gate hidden, app visible) */
.clerk-gate {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg, #f9fafb);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

body.clerk-loading .clerk-gate,
body.clerk-signed-out .clerk-gate,
body.clerk-failed .clerk-gate {
    display: flex;
}

/* Hide the rest of the app while the gate is up */
body.clerk-loading > .view,
body.clerk-signed-out > .view,
body.clerk-failed > .view {
    display: none !important;
}

.clerk-gate-shell {
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.clerk-gate-brand {
    margin-bottom: 32px;
}

.clerk-gate-brand img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg, 0 10px 15px rgba(0,0,0,0.1));
    margin-bottom: 16px;
}

.clerk-gate-brand h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text, #111827);
    margin: 0 0 6px;
}

.clerk-gate-brand p {
    color: var(--text-muted, #6b7280);
    font-size: 0.92rem;
    margin: 0;
}

.clerk-signin-container {
    display: flex;
    justify-content: center;
}

.clerk-loading-spinner {
    color: var(--text-muted, #6b7280);
    font-size: 0.9rem;
    padding: 40px;
}

/* User button (avatar with sign-out menu) — sits in landing header */
.clerk-user-button {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 10;
}

/* ===================== Voice (Web Speech + ElevenLabs TTS) ===================== */

/* Mic button — appears in chat input + guided conversation input +
   guided situation textarea (corner overlay variant) */
.voice-mic-btn {
    background: var(--bg, #f9fafb);
    border: 1px solid var(--border, #e5e7eb);
    color: var(--text-secondary, #6b7280);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    margin-right: 8px;
}

/* Wrapper that lets us overlay a mic button in the corner of the
   guided situation textarea (so the mic doesn't take a full row). */
.guided-situation-textarea-wrap {
    position: relative;
}
.voice-mic-btn-corner {
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 0;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.voice-mic-btn:hover {
    background: var(--accent-subtle, #eff6ff);
    color: var(--accent, #3b82f6);
    border-color: var(--accent, #3b82f6);
}

/* Listening — pulsing red ring */
.voice-mic-btn.voice-mic-listening {
    background: #fee2e2;
    color: #dc2626;
    border-color: #dc2626;
    animation: voice-mic-pulse 1.4s ease-in-out infinite;
}
@keyframes voice-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* Mute button visual when voice output is off */
.quick-btn.voice-muted,
.guided-header-cases-btn.voice-muted {
    opacity: 0.55;
}

/* Global "speaking" indicator — fixed bottom-right while TTS plays */
.voice-speaking-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9000;
    background: var(--primary, #1a1a2e);
    color: white;
    padding: 10px 16px;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: transform 0.15s;
}
.voice-speaking-indicator:hover {
    transform: scale(1.04);
}
.voice-speaker-icon {
    display: flex;
    align-items: center;
    color: var(--accent, #3b82f6);
}
.voice-waveform {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 18px;
}
.voice-waveform span {
    display: inline-block;
    width: 3px;
    background: var(--accent, #3b82f6);
    border-radius: 2px;
    animation: voice-waveform-pulse 0.9s ease-in-out infinite;
}
.voice-waveform span:nth-child(1) { height: 50%;  animation-delay: 0.0s; }
.voice-waveform span:nth-child(2) { height: 80%;  animation-delay: 0.15s; }
.voice-waveform span:nth-child(3) { height: 60%;  animation-delay: 0.3s; }
.voice-waveform span:nth-child(4) { height: 90%;  animation-delay: 0.45s; }
@keyframes voice-waveform-pulse {
    0%, 100% { transform: scaleY(0.6); }
    50%      { transform: scaleY(1.0); }
}
.voice-speaking-label { white-space: nowrap; }

/* "Thinking" indicator inside guided conversation bubble */
.conv-bubble-thinking {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg, #f9fafb) !important;
    color: var(--text-muted, #6b7280) !important;
    font-size: 0.85rem;
    font-style: italic;
}
.thinking-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}
.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent, #3b82f6);
    animation: thinking-bounce 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(1) { animation-delay: 0.0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%           { transform: scale(1.0); opacity: 1.0; }
}
.thinking-label {
    color: var(--text-muted, #6b7280);
}

.brand-name {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    display: block;
}

.brand-version {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.08);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.sidebar-status {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.3s;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.offline {
    background: var(--danger);
}

.status-dot.small {
    width: 6px;
    height: 6px;
}

.status-label {
    color: #9ca3af;
}

.sidebar-heading {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 10px;
}

.sidebar-modules {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.modules-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.module-tag {
    font-size: 0.8rem;
    padding: 6px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    color: #d1d5db;
    transition: background 0.2s;
}

.module-tag:hover {
    background: rgba(255,255,255,0.1);
}

.module-skeleton {
    height: 30px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

.sidebar-examples {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
}

.quick-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    margin-bottom: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #d1d5db;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.1);
    color: #fff;
}

.quick-btn svg {
    flex-shrink: 0;
    opacity: 0.5;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
    font-size: 0.7rem;
    color: #6b7280;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ===================== MOBILE HEADER ===================== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-height);
    background: var(--primary);
    color: white;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 100;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.mobile-brand-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
}

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

.mobile-overlay.active {
    display: block;
}

/* ===================== MAIN CHAT ===================== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-chat);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px 0;
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

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

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===================== WELCOME SCREEN ===================== */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 40px 20px;
    text-align: center;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    overflow: hidden;
}

.welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 20px;
}

.welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.welcome-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 480px;
    margin-bottom: 36px;
}

.welcome-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 680px;
}

.welcome-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: all 0.2s;
}

.welcome-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-subtle);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.card-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-text strong {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.card-text span {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ===================== MESSAGES ===================== */
.message {
    margin-bottom: 20px;
    animation: fadeUp 0.3s ease-out;
    max-width: 780px;
    margin-left: auto;
    margin-right: auto;
}

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

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-assistant {
    display: flex;
    justify-content: flex-start;
}

.message-user .message-content {
    background: var(--accent);
    color: white;
    border-radius: 16px 16px 4px 16px;
    padding: 12px 18px;
    max-width: 75%;
    font-size: 0.92rem;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

.message-assistant .message-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px 16px 16px 4px;
    padding: 16px 20px;
    max-width: 85%;
    font-size: 0.92rem;
    line-height: 1.7;
}

.message-assistant .message-content p {
    margin-bottom: 8px;
}

.message-assistant .message-content p:last-child {
    margin-bottom: 0;
}

/* Coverage / Confidence badges */
.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 12px;
    letter-spacing: 0.01em;
}

.confidence-high {
    background: var(--success-bg);
    color: var(--success-text);
}

.confidence-medium {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.confidence-low {
    background: var(--danger-bg);
    color: var(--danger-text);
}

/* Clarifying Questions */
.clarifying-questions {
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-top: 12px;
}

.clarifying-questions h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.clarifying-questions ol {
    margin-left: 18px;
    color: var(--text);
}

.clarifying-questions li {
    margin-bottom: 6px;
    font-size: 0.88rem;
}

/* Case Citations */
.case-citation {
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    padding: 14px 16px;
    margin: 12px 0;
    border-radius: 6px;
}

.case-citation .case-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    font-size: 0.88rem;
}

.case-citation .reasoning,
.case-citation .quote {
    margin: 8px 0;
    padding: 10px 12px;
    background: white;
    border-radius: 6px;
    font-size: 0.85rem;
}

.case-citation .reasoning strong,
.case-citation .quote strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Clarification understood */
.clarification-understood {
    background: var(--success-bg);
    border: 1px solid #a7f3d0;
    padding: 10px 14px;
    margin-bottom: 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--success-text);
}

/* System messages */
.system-message-content {
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.system-message-content.error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #fecaca;
}

.system-message-content.info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.system-message-content.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #a7f3d0;
}

/* ===================== TYPING INDICATOR ===================== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 24px 16px;
    max-width: 780px;
    margin: 0 auto;
}

.typing-indicator.hidden {
    display: none;
}

.typing-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.typing-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ===================== INPUT AREA ===================== */
.input-wrapper {
    padding: 0 24px 20px;
    background: var(--bg-chat);
    max-width: 828px;
    margin: 0 auto;
    width: 100%;
}

.input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 6px 6px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-area:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.92rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    padding: 8px 0;
    max-height: 150px;
    color: var(--text);
    background: transparent;
}

#user-input::placeholder {
    color: var(--text-muted);
}

#send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

#send-btn:hover {
    background: var(--accent-hover);
}

#send-btn:active {
    transform: scale(0.95);
}

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

.btn-spinner {
    animation: spin 0.8s linear infinite;
}

.btn-spinner.hidden {
    display: none;
}

#send-icon.hidden {
    display: none;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.input-hint {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
}

.input-hint kbd {
    font-family: inherit;
    font-size: 0.68rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--text-secondary);
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 200;
        transition: left 0.3s ease;
        width: 280px;
    }

    .sidebar.open {
        left: 0;
    }

    .mobile-header {
        display: flex;
    }

    .chat-main {
        padding-top: var(--mobile-header-height);
    }

    .chat-container {
        padding: 16px 16px 0;
    }

    .input-wrapper {
        padding: 0 12px 12px;
    }

    .welcome-title {
        font-size: 1.25rem;
    }

    .welcome-cards {
        grid-template-columns: 1fr;
    }

    .message-user .message-content {
        max-width: 85%;
    }

    .message-assistant .message-content {
        max-width: 92%;
    }
}

@media (min-width: 769px) {
    .mobile-header {
        display: none !important;
    }
}

/* ===================== DARK SCROLLBAR FOR SIDEBAR ===================== */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

/* ===================== VIEW SYSTEM ===================== */
.view {
    display: none;
    height: 100vh;
    overflow: hidden;
}

.view-active {
    display: block;
}

/* When chat view is active, its app-shell should fill the viewport */
#view-chat.view-active {
    display: block;
}

#view-chat .app-shell {
    height: 100vh;
}

/* ===================== LANDING PAGE ===================== */
.landing-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--bg);
}

.landing-header {
    text-align: center;
    margin-bottom: 48px;
}

.landing-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    overflow: hidden;
    margin: 0 auto 20px;
    box-shadow: var(--shadow-lg);
}

.landing-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.landing-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.landing-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.landing-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-width: 720px;
    width: 100%;
}

.landing-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 36px 28px 28px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    transition: all 0.25s ease;
}

.landing-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.landing-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.landing-card-icon--guided {
    background: #ecfdf5;
    color: var(--success);
}

.landing-card-icon--chat {
    background: var(--accent-subtle);
    color: var(--accent);
}

.landing-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.landing-card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.landing-card-cta {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    margin-top: auto;
}

.landing-footer {
    margin-top: 48px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Back to Home link in sidebar */
.sidebar-nav-home {
    padding: 8px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* ===================== GUIDED SHELL ===================== */
.guided-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.guided-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    flex-shrink: 0;
}

.guided-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
    min-height: 44px;
}

.guided-back-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.guided-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    margin-left: auto;
}

.guided-header-brand img {
    border-radius: 6px;
}

.guided-header-cases-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.92);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 7px 12px;
    border-radius: 6px;
    margin-left: 12px;
    transition: all 0.15s;
    min-height: 36px;
}

.guided-header-cases-btn:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.22);
}

.guided-cases-count {
    background: var(--accent, #3b82f6);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 2px;
}

/* Saved cases list */
.cases-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.case-row {
    background: white;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.15s;
}

.case-row:hover {
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.case-row-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text, #111827);
    margin-bottom: 4px;
}

.case-row-meta {
    font-size: 0.78rem;
    color: var(--text-muted, #6b7280);
}

.cases-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted, #6b7280);
}

.cases-empty-hint {
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Case viewer */
.case-view-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.case-view-toolbar .guided-back-btn {
    color: var(--text, #111827);
    padding: 6px 10px;
}

.case-view-toolbar .guided-back-btn:hover {
    background: rgba(0,0,0,0.05);
}

.case-view-download,
.case-view-delete {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border, #e5e7eb);
    color: var(--text, #111827);
    font-family: inherit;
    font-size: 0.82rem;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.case-view-download { margin-left: auto; }
.case-view-delete { margin-left: 0; color: #dc2626; border-color: #fecaca; }

.case-view-download:hover {
    background: var(--accent, #3b82f6);
    color: white;
    border-color: var(--accent, #3b82f6);
}

.case-view-delete:hover {
    background: #fee2e2;
}

.case-view-content {
    background: white;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    padding: 28px 32px;
    line-height: 1.6;
    color: var(--text, #111827);
}

.case-view-content h1 { font-size: 1.5rem; margin: 0 0 8px; }
.case-view-content h2 { font-size: 1.15rem; margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border, #e5e7eb); }
.case-view-content h3 { font-size: 1rem; margin: 18px 0 8px; color: var(--accent, #3b82f6); }
.case-view-content p { margin: 8px 0; }
.case-view-content ul { margin: 8px 0 8px 20px; padding: 0; }
.case-view-content li { margin: 4px 0; }
.case-view-content blockquote {
    margin: 8px 0;
    padding: 8px 14px;
    border-left: 3px solid var(--accent, #3b82f6);
    background: #f9fafb;
    color: var(--text, #111827);
}
.case-view-content blockquote p { margin: 4px 0; }
.case-view-content hr { border: none; border-top: 1px solid var(--border, #e5e7eb); margin: 20px 0; }
.case-view-content code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 0.85em; }

/* Save Case button */
.advice-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.guided-save-case-btn {
    background: var(--accent, #3b82f6);
    color: white;
    border: none;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.guided-save-case-btn:hover {
    background: #2563eb;
}

.guided-save-case-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.guided-export-pdf-btn {
    background: white;
    color: var(--accent, #3b82f6);
    border: 1px solid var(--accent, #3b82f6);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.guided-export-pdf-btn:hover {
    background: var(--accent, #3b82f6);
    color: white;
}

.guided-header-spacer {
    width: 80px;
}

/* Progress Bar */
.guided-progress-wrap {
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.guided-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}

.guided-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.guided-progress-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 90px;
    text-align: right;
}

/* Guided Content */
.guided-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
}

.guided-subview {
    display: none;
}

.guided-subview-active {
    display: block;
}

.guided-section-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    text-align: center;
}

.guided-section-desc {
    font-size: 0.92rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 540px;
    margin: 0 auto 32px;
}

/* Topic Grid */
.guided-topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    max-width: 860px;
    margin: 0 auto;
}

.guided-topic-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 24px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: all 0.25s ease;
}

.guided-topic-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.guided-topic-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.guided-topic-card-desc {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.guided-topic-card-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
}

/* ===================== STEPPER ===================== */
.stepper-layout {
    display: flex;
    gap: 28px;
    max-width: 960px;
    margin: 0 auto;
}

.stepper-main {
    flex: 1;
    min-width: 0;
}

.stepper-question-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    animation: fadeUp 0.3s ease-out;
}

.stepper-q-number {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 12px;
}

.stepper-q-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 8px;
}

.stepper-q-source {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Question Inputs */
.stepper-q-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stepper-yn-group {
    display: flex;
    gap: 12px;
}

.stepper-yn-btn {
    flex: 1;
    padding: 14px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
}

.stepper-yn-btn--yes {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1.5px solid #a7f3d0;
}

.stepper-yn-btn--yes:hover {
    background: #d1fae5;
    border-color: var(--success);
}

.stepper-yn-btn--no {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1.5px solid #fecaca;
}

.stepper-yn-btn--no:hover {
    background: #fee2e2;
    border-color: var(--danger);
}

.stepper-choice-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.92rem;
    transition: all 0.2s;
    min-height: 48px;
}

.stepper-choice-label:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.stepper-choice-label input {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
}

.stepper-text-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.92rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s;
    min-height: 48px;
}

.stepper-text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.stepper-text-submit {
    align-self: flex-end;
    padding: 10px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.2s;
}

.stepper-text-submit:hover {
    background: var(--accent-hover);
}

/* Stepper Nav */
.stepper-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.stepper-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.stepper-nav-prev {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.stepper-nav-prev:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.stepper-nav-skip {
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 500;
}

.stepper-nav-skip:hover {
    color: var(--text-secondary);
}

/* Analysis CTA */
.guided-analysis-cta {
    margin-top: 24px;
    padding: 20px;
    background: var(--accent-subtle);
    border: 1.5px solid rgba(79, 110, 247, 0.2);
    border-radius: var(--radius-lg);
    text-align: center;
}

.guided-analysis-ready {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.guided-analysis-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
    transition: all 0.2s;
}

.guided-analysis-btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

.guided-analysis-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Analysis Result */
.guided-result {
    margin-top: 24px;
    animation: fadeUp 0.4s ease-out;
}

.guided-result-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}

.guided-result-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    font-size: 0.92rem;
    line-height: 1.7;
}

.guided-result-content p {
    margin-bottom: 8px;
}

.guided-result-content strong {
    font-weight: 600;
}

.guided-startover-btn {
    margin-top: 20px;
    padding: 10px 24px;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    min-height: 44px;
    transition: all 0.2s;
}

.guided-startover-btn:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

/* Done state */
.guided-done {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
}

/* Sidebar */
.stepper-sidebar {
    width: 280px;
    flex-shrink: 0;
}

.stepper-sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.stepper-sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 260px);
    overflow-y: auto;
}

.stepper-sidebar-empty {
    font-size: 0.84rem;
    color: var(--text-muted);
}

.stepper-sidebar-item {
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.8rem;
}

.stepper-sidebar-item-q {
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.stepper-sidebar-item-a {
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
}

.stepper-sidebar-item-a.answer-yes {
    color: var(--success-text);
}

.stepper-sidebar-item-a.answer-no {
    color: var(--danger-text);
}

/* Loading spinner for guided */
.guided-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.guided-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===================== SITUATION ENTRY ===================== */
.guided-situation-area {
    max-width: 680px;
    margin: 0 auto;
}

.guided-situation-textarea {
    width: 100%;
    padding: 16px;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    outline: none;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}

.guided-situation-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.guided-situation-textarea::placeholder {
    color: var(--text-muted);
}

.guided-situation-error {
    padding: 10px 14px;
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.guided-situation-area .guided-analysis-btn {
    width: 100%;
    justify-content: center;
}

.guided-examples {
    margin-top: 24px;
}

.guided-examples-label {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.guided-examples-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.guided-example-btn {
    padding: 10px 14px;
    font-size: 0.82rem;
    font-family: inherit;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    line-height: 1.4;
}

.guided-example-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* ===================== EXTRACTION SUMMARY ===================== */
.guided-extraction-summary {
    padding: 20px;
    background: var(--success-bg);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    animation: fadeUp 0.3s ease-out;
}

.guided-extraction-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--success-text);
    margin-bottom: 12px;
}

.guided-extraction-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.guided-extraction-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    padding: 6px 10px;
    background: white;
    border-radius: 6px;
}

.guided-extraction-check {
    color: var(--success);
    font-weight: 700;
    flex-shrink: 0;
}

.guided-extraction-label {
    flex: 1;
    color: var(--text);
}

.guided-extraction-source {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    flex-shrink: 0;
}

.guided-extraction-modules {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.guided-extraction-gap {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 12px;
    font-weight: 500;
}

/* ===================== CONVERSATION THREAD ===================== */
.conv-layout {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
}

.conv-thread {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

.conv-msg { animation: fadeUp 0.3s ease-out; }
.conv-user { display: flex; justify-content: flex-end; }
.conv-system { display: flex; justify-content: flex-start; }

.conv-bubble {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.6;
}

.conv-bubble-user {
    background: var(--accent);
    color: white;
    border-radius: 14px 14px 4px 14px;
}

.conv-bubble-system {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px 14px 14px 4px;
}

.conv-bubble-question {
    background: var(--accent-subtle);
    border: 1px solid rgba(79, 110, 247, 0.2);
    border-radius: 14px 14px 14px 4px;
}

.conv-q-text {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.conv-extractions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.conv-extraction-item {
    font-size: 0.85rem;
    padding: 4px 8px;
    background: white;
    border-radius: 4px;
}

.conv-check { color: var(--success); font-weight: 700; margin-right: 4px; }
.conv-modules { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }
.conv-understanding { font-size: 0.88rem; color: var(--text-secondary); margin-top: 6px; }

.conv-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    position: sticky;
    bottom: 0;
    background: var(--bg);
}

.conv-text-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.92rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    outline: none;
    min-height: 48px;
}

.conv-text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.conv-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.conv-advice-cta {
    text-align: center;
    padding: 20px;
    background: var(--accent-subtle);
    border: 1.5px solid rgba(79, 110, 247, 0.2);
    border-radius: var(--radius-lg);
    margin-top: 12px;
}

.conv-advice-cta p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ===================== ADVICE DISPLAY ===================== */
.advice-layout {
    max-width: 780px;
    margin: 0 auto;
}

.advice-content {
    margin-top: 16px;
}

.advice-section {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.advice-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.advice-section-hint {
    font-size: 0.8125rem;
    color: var(--text-muted, #6b7280);
    font-style: italic;
    line-height: 1.45;
    margin: -6px 0 14px 0;
}

.advice-rule {
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 10px;
}

.advice-rule-citation {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 4px;
}

.advice-rule-text {
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 6px;
}

.advice-rule-relevance {
    font-size: 0.84rem;
    color: var(--success-text);
    font-style: italic;
}

.advice-case {
    padding: 12px;
    background: var(--bg);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 10px;
}

.advice-case-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 4px;
}

.advice-case-court {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.advice-case-sim-stars {
    color: #f5b301;
    letter-spacing: 1px;
    font-weight: normal;
}

.advice-case-relevance {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.5;
}

.advice-case-rule {
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 500;
}

.advice-cross {
    padding: 10px 12px;
    background: var(--accent-subtle);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.advice-cross-link {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 4px;
}

.advice-cross-explain {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.advice-missing {
    background: var(--warning-bg);
    border-color: #fde68a;
}

.advice-missing h3 { color: var(--warning-text); }

/* ===================== PROMPT INSPECTOR (Easter Egg) ===================== */
.prompt-inspector-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.pi-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.pi-panel {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    padding: 24px;
    z-index: 1;
}

.pi-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.pi-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.pi-stats {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: auto;
}

.pi-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    line-height: 1;
}

.pi-close:hover { color: var(--text); }

.pi-custom-note {
    background: var(--warning-bg);
    color: var(--warning-text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 12px;
}

.pi-textarea {
    width: 100%;
    min-height: 300px;
    padding: 14px;
    font-size: 0.82rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    line-height: 1.5;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
    outline: none;
    color: var(--text);
    background: var(--bg);
}

.pi-textarea:focus {
    border-color: var(--accent);
}

.pi-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.pi-btn {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    border: none;
    min-height: 40px;
}

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

.pi-btn-save:hover { background: var(--accent-hover); }

.pi-btn-reset {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
}

.pi-btn-reset:hover { border-color: var(--text-muted); }

.pi-history {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.pi-history h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.pi-history-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pi-msg {
    font-size: 0.78rem;
    padding: 6px 10px;
    border-radius: 6px;
    line-height: 1.4;
}

.pi-msg-user { background: var(--accent-subtle); color: var(--text); }
.pi-msg-assistant { background: var(--bg); color: var(--text-secondary); }

/* R8: Tree Health tab in the prompt inspector modal */
.pi-tabs {
    display: flex;
    gap: 4px;
    margin: 12px 0;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.pi-tab {
    background: none;
    border: none;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.pi-tab:hover { color: var(--text, #111827); }
.pi-tab-active {
    color: var(--accent, #3b82f6);
    border-bottom-color: var(--accent, #3b82f6);
}
.pi-section h4 {
    font-size: 0.95rem;
    margin: 12px 0 4px;
    color: var(--text, #111827);
}
.pi-section h5 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #6b7280);
    margin: 14px 0 4px;
}
.pi-muted { font-size: 0.8rem; color: var(--text-muted, #6b7280); margin: 4px 0 12px; }
.pi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin: 4px 0 8px;
}
.pi-table th, .pi-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    text-align: left;
}
.pi-table th {
    color: var(--text-muted, #6b7280);
    font-weight: 600;
}
.pi-table code { font-size: 0.85em; }
.pi-tree-health ul {
    font-size: 0.82rem;
    padding-left: 18px;
    margin: 4px 0 8px;
}

/* ===================== AMEND STEP ===================== */
.conv-amend-prompt {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.conv-amend-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.conv-amend-slot-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-family: inherit;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s;
}

.conv-amend-slot-btn:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.conv-amend-edit {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 500;
}

.conv-amend-add {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.conv-amend-add .conv-text-input {
    flex: 1;
    min-height: 40px;
    font-size: 0.88rem;
}

.conv-amend-add .conv-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.conv-confirm-btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.9rem;
}

/* ===================== LEGAL REFERENCE ON QUESTIONS ===================== */
.stepper-legal-ref {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
}

.stepper-explanatory {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
}

/* Cross-module badge */
.guided-cross-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-subtle);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
}

/* Free text card on scenario screen */
.guided-freetext-card {
    padding: 24px;
    background: var(--surface);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
}

.guided-freetext-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.guided-freetext-row {
    display: flex;
    gap: 8px;
}

.guided-freetext-row .stepper-text-input {
    flex: 1;
}

/* Redirect notice */
.guided-redirect-notice {
    padding: 28px;
    background: var(--warning-bg);
    border: 1.5px solid #fde68a;
    border-radius: var(--radius-lg);
    text-align: center;
}

.guided-redirect-notice h3 {
    font-size: 1.1rem;
    color: var(--warning-text);
    margin-bottom: 12px;
}

.guided-redirect-notice p {
    font-size: 0.92rem;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Completeness summary */
.guided-completeness {
    margin-top: 20px;
    padding: 24px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    animation: fadeUp 0.3s ease-out;
}

.guided-completeness-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.guided-completeness-known {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.guided-completeness-item {
    font-size: 0.85rem;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: 6px;
}

.guided-completeness-missing {
    margin-top: 12px;
    padding: 14px;
    background: var(--warning-bg);
    border: 1px solid #fde68a;
    border-radius: var(--radius);
}

.guided-completeness-missing h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--warning-text);
    margin-bottom: 10px;
}

.guided-completeness-missing-item {
    display: flex;
    gap: 8px;
    font-size: 0.84rem;
    margin-bottom: 8px;
    align-items: flex-start;
}

.guided-warning-icon {
    color: var(--warning);
    font-size: 1rem;
    flex-shrink: 0;
}

.guided-impact {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===================== RESPONSIVE: LANDING ===================== */
@media (max-width: 640px) {
    .landing-cards {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .landing-card {
        padding: 28px 20px 20px;
    }

    .landing-title {
        font-size: 1.5rem;
    }

    .stepper-layout {
        flex-direction: column;
    }

    .stepper-sidebar {
        width: 100%;
        order: -1;
    }

    .stepper-sidebar-list {
        max-height: none;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .stepper-sidebar-item {
        flex: 1 1 auto;
        min-width: 140px;
    }

    .stepper-question-card {
        padding: 20px;
    }

    .stepper-yn-group {
        flex-direction: column;
    }

    .guided-header-spacer {
        display: none;
    }

    .guided-content {
        padding: 20px 16px;
    }

    .guided-topic-grid {
        grid-template-columns: 1fr;
    }

    .guided-examples-grid {
        grid-template-columns: 1fr;
    }
}

/* ===================== CC-S44: Reasonex pilot UI ===================== */
:root { --reasonex-banner-h: 38px; }

.reasonex-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 10000;
    min-height: var(--reasonex-banner-h); box-sizing: border-box;
    display: flex; align-items: center; gap: 6px;
    padding: 6px 16px;
    background: #7a2e0e; color: #fff;
    font-size: 0.78rem; line-height: 1.3;
    border-bottom: 1px solid rgba(0,0,0,0.2);
}
.reasonex-banner strong { color: #ffd9c2; }
.reasonex-banner em { font-style: italic; opacity: 0.95; }

/* Reserve space below the fixed banner */
.view { margin-top: var(--reasonex-banner-h); height: calc(100vh - var(--reasonex-banner-h)); }
.landing-page { min-height: calc(100vh - var(--reasonex-banner-h)); }
#view-chat .app-shell { height: calc(100vh - var(--reasonex-banner-h)); }
.clerk-gate { inset: var(--reasonex-banner-h) 0 0 0; }

/* First-visit acknowledgment modal */
.disclaimer-modal { position: fixed; inset: 0; z-index: 10001; background: rgba(15,23,42,0.7); display: flex; align-items: center; justify-content: center; padding: 20px; }
.disclaimer-modal[hidden] { display: none; }
.disclaimer-card { background: #fff; color: #1f2937; max-width: 520px; width: 100%; border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.disclaimer-card h2 { margin: 0 0 12px; font-size: 1.25rem; }
.disclaimer-card p { margin: 0 0 12px; font-size: 0.92rem; line-height: 1.5; }
.disclaimer-card ul { margin: 0 0 16px; padding-left: 20px; font-size: 0.88rem; line-height: 1.5; }
.disclaimer-card li { margin-bottom: 6px; }
.disclaimer-ack { display: flex; align-items: flex-start; gap: 8px; font-size: 0.9rem; margin-bottom: 18px; cursor: pointer; }
.disclaimer-ack input { margin-top: 3px; }
.disclaimer-accept { width: 100%; padding: 12px; border: none; border-radius: 10px; background: #1d4ed8; color: #fff; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.disclaimer-accept:disabled { background: #9ca3af; cursor: not-allowed; }
body.disclaimer-open { overflow: hidden; }

/* Corridor rendering */
.reasonex-inline-disclaimer { font-size: 0.74rem; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 6px 10px; margin-bottom: 12px; }
.reasonex-facts { font-size: 0.8rem; margin-bottom: 14px; color: #475569; }
.reasonex-facts-label { font-weight: 600; }
.fact-chip { display: inline-block; background: #eef2ff; color: #3730a3; border-radius: 12px; padding: 2px 9px; margin: 2px 3px; font-size: 0.74rem; }
.corridor-h { font-size: 0.95rem; margin: 6px 0 10px; }
.corridor { border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.corridor-complete { border-left: 4px solid #16a34a; }
.corridor-pending { border-left: 4px solid #d97706; }
.corridor-blocked { border-left: 4px solid #9ca3af; opacity: 0.85; }
.corridor-path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.corridor-step { background: #f1f5f9; border-radius: 6px; padding: 2px 7px; }
.corridor-step-fired { background: #dcfce7; color: #166534; }
.corridor-step-pending { background: #fef3c7; color: #92400e; }
.corridor-step-blocked, .corridor-step-missing_rule { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }
.corridor-arrow { color: #94a3b8; }
.corridor-terminal { font-size: 0.78rem; color: #0f766e; margin-top: 6px; }
.corridor-needs { font-size: 0.76rem; color: #92400e; margin-top: 6px; }
.corridor-none { font-size: 0.86rem; color: #475569; }
.corridor-collapse { margin: 8px 0; }
.corridor-expand { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 8px 12px; width: 100%; text-align: left; cursor: pointer; font-size: 0.84rem; color: #334155; }
.corridor-expand::after { content: " \25B8"; }
.corridor-expand.open::after { content: " \25BE"; }
.corridor-expand-muted { color: #64748b; font-size: 0.8rem; }
.corridor-pending-intro { font-size: 0.82rem; margin: 10px 0 6px; }
.corridor-pending-facts { margin: 0 0 12px; padding-left: 20px; font-size: 0.82rem; }
.corridor-detail { padding: 10px 4px 2px; }
.brand-module { font-size: 0.82rem; color: var(--text-muted, #6b7280); margin: 4px 0 0; }
