/* ===== CSS Variables ===== */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    --border-color: #e5e7eb;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-md: 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    
    --transition: all 0.15s ease;
}

/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== Sticky Action Bar ===== */
.sticky-action-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    display: none; /* Hidden initially, shown after scroll */
}

.sticky-action-bar.visible {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.sticky-bar-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sticky-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sticky-sessions-btn {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.sticky-sessions-btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
}

.session-count-badge {
    background: rgba(255, 255, 255, 0.25);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

.sticky-bar-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

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

.sticky-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.sticky-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.sticky-btn.success {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.sticky-btn svg {
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .sticky-btn span {
        display: none;
    }
    
    .sticky-btn {
        padding: 8px;
    }
    
    .sticky-bar-title {
        font-size: 14px;
    }
}

/* ===== Login Modal ===== */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.login-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    max-width: 450px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.4s ease-out;
}

.login-header {
    padding: 32px 32px 24px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.login-header h2 {
    font-size: 24px;
    margin: 0 0 8px 0;
}

.login-header p {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
}

.login-body {
    padding: 32px;
}

.login-input-group {
    margin-bottom: 20px;
}

.login-input-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-family: inherit;
    transition: var(--transition);
}

.login-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.login-error {
    padding: 12px;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: var(--border-radius);
    color: var(--error-color);
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-error::before {
    content: '⚠️';
}

.login-body button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-bottom: 16px;
}

.login-hint {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

/* ===== Consent Modal ===== */
.consent-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.consent-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease-out;
}

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

.consent-header {
    padding: 24px 24px 16px;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.consent-header h2 {
    font-size: 22px;
    margin: 0;
}

.consent-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.consent-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.consent-section:last-of-type {
    border-bottom: none;
}

.consent-section h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.consent-section p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
}

.consent-section ul {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.consent-section li {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
    padding-left: 24px;
    position: relative;
}

.consent-section li::before {
    content: '•';
    position: absolute;
    left: 8px;
    color: var(--primary-color);
    font-weight: bold;
}

.consent-link {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 3px solid var(--primary-color);
}

.consent-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.consent-link a:hover {
    border-bottom-color: var(--primary-color);
}

.consent-checkbox {
    margin-top: 20px;
    padding: 16px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: var(--border-radius);
}

.consent-checkbox label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.consent-checkbox input[type="checkbox"] {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.consent-checkbox span {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    font-weight: 500;
}

.consent-footer {
    padding: 20px 24px;
    border-top: 2px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

.consent-footer button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.consent-footer button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scrollbar styling for consent modal */
.consent-body::-webkit-scrollbar {
    width: 8px;
}

.consent-body::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.consent-body::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.consent-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 16px;
}

/* ===== Container ===== */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding-top: 0; /* Space for sticky bar when visible */
}

.container.sticky-visible {
    padding-top: 52px;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 24px;
    animation: fadeInDown 0.5s ease;
}

.header-content {
    background: var(--bg-primary);
    padding: 24px 20px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    font-weight: 400;
}

.badge {
    display: none;
}

/* ===== Card Component ===== */
.card {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
    animation: fadeInUp 0.5s ease;
}

.card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

/* ===== Input Section ===== */
.hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 12px;
}

#caseInput {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    resize: vertical;
    transition: var(--transition);
    background: var(--bg-primary);
}

#caseInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

#caseInput::placeholder {
    color: var(--text-tertiary);
}

.char-counter {
    text-align: right;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    margin-top: 6px;
}

/* ===== Theoretical Focus Section ===== */
.focus-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: var(--transition);
    background: var(--bg-primary);
}

.focus-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.focus-input::placeholder {
    color: var(--text-tertiary);
}

.focus-note {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-top: 8px;
    margin-bottom: 0;
    font-style: italic;
}

/* ===== Radio Group ===== */
.radio-group {
    display: grid;
    gap: 12px;
}

.radio-card {
    position: relative;
    cursor: pointer;
    display: block;
}

.radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.radio-content {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    transition: var(--transition);
}

.radio-card:hover .radio-content {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}

.radio-card input[type="radio"]:checked + .radio-content {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.04);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.radio-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.radio-text h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    letter-spacing: -0.01em;
}

.radio-text p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ===== Buttons ===== */
.action-section {
    text-align: center;
    margin: 20px 0;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 32px;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-tertiary);
}

/* ===== Results Section ===== */
.results-section {
    animation: fadeInUp 0.6s ease;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

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

.results-actions .btn-secondary {
    padding: 8px 14px;
    font-size: 13px;
}

/* ===== Loading State ===== */
.loading-state {
    text-align: center;
    padding: 48px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-state p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.loading-hint {
    font-size: 0.8125rem !important;
    color: var(--text-tertiary) !important;
    margin-top: 8px;
}

/* ===== Streaming Cursor Animation ===== */
@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.results-content.is-streaming::after,
.conversation-answer.is-streaming::after {
    content: '▋';
    display: inline;
    color: var(--primary-color);
    animation: blink-cursor 0.8s ease-in-out infinite;
    margin-left: 2px;
    font-weight: normal;
}

/* Smooth text appearance during streaming */
.results-content.is-streaming {
    animation: none;
}

/* ===== Hypothesis & Open Questions Styling ===== */

/* Hypothesen-Box - für Absätze die Hypothesen enthalten */
.results-content .hypothesis-box,
.results-content blockquote.hypothesis {
    background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
    border-left: 4px solid #eab308;
    padding: 16px 20px;
    border-radius: 0 12px 12px 0;
    margin: 20px 0;
    position: relative;
}

.results-content .hypothesis-box::before,
.results-content blockquote.hypothesis::before {
    content: '💡 Hypothese';
    display: block;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a16207;
    margin-bottom: 8px;
}

/* Offene Fragen Box */
.results-content .open-questions-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 2px dashed #3b82f6;
    padding: 20px;
    border-radius: 12px;
    margin: 24px 0;
}

.results-content .open-questions-box::before {
    content: '❓ Offene Fragen';
    display: block;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #1d4ed8;
    margin-bottom: 12px;
}

/* Handlungsoptionen Box */
.results-content .options-box {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-left: 4px solid #22c55e;
    padding: 16px 20px;
    border-radius: 0 12px 12px 0;
    margin: 20px 0;
}

.results-content .options-box::before {
    content: '🎯 Handlungsoption';
    display: block;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #15803d;
    margin-bottom: 8px;
}

/* Literatur-Tags */
.results-content .literature-section {
    background: var(--bg-tertiary);
    padding: 16px 20px;
    border-radius: 12px;
    margin: 24px 0;
}

.results-content .literature-tag {
    display: inline-block;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    margin: 4px 4px 4px 0;
    transition: var(--transition);
}

.results-content .literature-tag:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== Example Cases ===== */
.example-cases {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.example-cases-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

.example-cases-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.example-case-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.example-case-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.example-case-btn.selected {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(0.98);
}

.example-case-btn .case-icon {
    font-size: 14px;
}

.example-case-btn .case-text {
    white-space: nowrap;
}

@media (max-width: 480px) {
    .example-cases-buttons {
        flex-direction: column;
    }
    
    .example-case-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== Results Content ===== */
.results-content {
    line-height: 1.7;
    color: var(--text-primary);
    font-size: 0.9375rem;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 8px;
    scroll-behavior: smooth;
    position: relative;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    padding: 16px;
    margin: -16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Hover state - zeigt dass der Bereich scrollbar ist */
.results-content:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    cursor: default;
}

/* Focus state für Keyboard-Navigation */
.results-content:focus-within {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Fade-out Gradient am unteren Rand wenn mehr Inhalt verfügbar */
.results-content::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, var(--bg-primary));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.results-content.has-more-content::after {
    opacity: 1;
}

/* Scroll Progress Indicator für results-content */
.results-scroll-indicator {
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.results-content:hover .results-scroll-indicator,
.results-content:focus-within .results-scroll-indicator {
    opacity: 1;
}

.results-scroll-indicator-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    width: 0%;
    transition: width 0.1s ease;
    border-radius: 2px;
}

/* Scrollbar styling for results content */
.results-content::-webkit-scrollbar {
    width: 10px;
}

.results-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 5px;
}

.results-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
    transition: background 0.2s ease;
}

.results-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

.results-content h1,
.results-content h2,
.results-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.results-content h1 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.results-content h2 {
    font-size: 1.25rem;
}

.results-content h3 {
    font-size: 1.0625rem;
}

.results-content p {
    margin-bottom: 1em;
}

.results-content ul,
.results-content ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

.results-content li {
    margin-bottom: 0.5em;
}

.results-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.results-content em {
    font-style: italic;
    color: var(--text-secondary);
}

.results-content code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.results-content pre {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin-bottom: 1em;
}

.results-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 20px;
    margin: 1em 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* ===== Error Message ===== */
.error-message {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fef2f2;
    border: 2px solid var(--error-color);
    color: #991b1b;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    margin: 20px 0;
    animation: shake 0.5s ease;
}

.error-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.error-text {
    font-weight: 500;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 24px 20px;
    color: var(--text-secondary);
    margin-top: 32px;
}

.footer p {
    margin-bottom: 8px;
    font-size: 0.8125rem;
}

.footer-note {
    font-size: 0.75rem;
    opacity: 0.85;
    line-height: 1.5;
}

/* ===== Animations ===== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

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

    .card {
        padding: 16px;
    }

    .radio-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .results-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.375rem;
    }

    .subtitle {
        font-size: 0.875rem;
    }

    .card h2 {
        font-size: 1rem;
    }
}

/* ===== Analysis Domain Section (NEW) ===== */
.domain-section {
    margin-top: 16px;
}

.domain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.domain-option {
    display: block;
    cursor: pointer;
}

.domain-option input[type="radio"] {
    display: none;
}

.domain-content {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    transition: var(--transition);
    height: 100%;
}

.domain-option:hover .domain-content {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.domain-option:has(input[type="radio"]:checked) .domain-content {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.domain-icon {
    font-size: 28px;
    flex-shrink: 0;
    margin-top: 2px;
}

.domain-text {
    flex: 1;
    min-width: 0;
}

.domain-text strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.domain-text small {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Custom Domain Option - Highlight */
.domain-option-custom .domain-content {
    border-style: dashed;
}

.domain-option-custom:has(input[type="radio"]:checked) .domain-content {
    border-style: solid;
}

/* Custom Domain Input */
.custom-domain-input {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.custom-domain-input label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 14px;
}

.custom-domain-input textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.custom-domain-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.custom-domain-input textarea::placeholder {
    color: var(--text-tertiary);
    font-style: italic;
}

/* Responsive: Stacked on mobile */
@media (max-width: 640px) {
    .domain-grid {
        grid-template-columns: 1fr;
    }
    
    .domain-content {
        padding: 14px;
    }
    
    .domain-icon {
        font-size: 24px;
    }
    
    .domain-text strong {
        font-size: 14px;
    }
}

/* ===== Analysis Depth Section ===== */
.depth-section {
    margin-top: 16px;
}

.depth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
    margin-bottom: 16px;
    text-align: center;
}

.depth-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.depth-option {
    display: block;
    cursor: pointer;
}

.depth-option input[type="radio"] {
    display: none;
}

.depth-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    transition: var(--transition);
    height: 100%;
}

.depth-option:hover .depth-content {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.depth-option:has(input[type="radio"]:checked) .depth-content {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.depth-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.depth-text h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.depth-text p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.depth-tokens {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
}

.depth-option:has(input[type="radio"]:checked) .depth-tokens {
    background: var(--primary-color);
    color: white;
}

/* ===== Research Toggle Section (Top) ===== */
.research-toggle-section {
    margin-top: 16px;
    padding: 0;
    overflow: hidden;
}

.research-toggle-btn {
    width: 100%;
    padding: 16px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
}

.research-toggle-btn:hover {
    background: var(--bg-tertiary);
}

.toggle-icon {
    font-size: 20px;
}

.toggle-text {
    flex: 1;
    text-align: left;
}

.toggle-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.research-toggle-btn.active .toggle-arrow {
    transform: rotate(180deg);
}

.research-toggle-content {
    padding: 20px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.research-info {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 3px solid var(--primary-color);
}

.research-modes-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.research-option-compact {
    display: block;
    cursor: pointer;
}

.research-option-compact input[type="radio"] {
    display: none;
}

.option-content-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    transition: var(--transition);
    font-size: 14px;
}

.research-option-compact:hover .option-content-compact {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}

.research-option-compact:has(input[type="radio"]:checked) .option-content-compact {
    border-color: var(--primary-color);
    background: #eef2ff;
    color: var(--primary-color);
    font-weight: 500;
}

.canton-input-compact,
.custom-focus-input-compact {
    grid-column: 1 / -1;
    margin-top: 4px;
}

.canton-input-compact input,
.custom-focus-input-compact textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
}

.canton-input-compact input:focus,
.custom-focus-input-compact textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.custom-focus-input-compact textarea {
    resize: vertical;
}

/* ===== Research Section (After Analysis) ===== */
.research-section {
    margin-top: 24px;
    animation: slideIn 0.3s ease-out;
}

.research-header {
    margin-bottom: 24px;
    text-align: center;
}

.research-header h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.research-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.research-modes {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.research-option {
    display: block;
    cursor: pointer;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 16px;
    transition: var(--transition);
    background: var(--bg-primary);
}

.research-option:hover {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}

.research-option input[type="radio"] {
    display: none;
}

.research-option input[type="radio"]:checked + .option-content {
    color: var(--primary-color);
}

.research-option input[type="radio"]:checked ~ .option-content {
    color: var(--primary-color);
}

.research-option:has(input[type="radio"]:checked) {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.option-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.option-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
}

.option-text strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
}

.option-text small {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
}

.canton-input,
.custom-focus-input {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.canton-input label,
.custom-focus-input label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.canton-input input,
.custom-focus-input textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.canton-input input:focus,
.custom-focus-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.custom-focus-input textarea {
    resize: vertical;
    min-height: 80px;
}

.research-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.research-results-header h3 {
    font-size: 18px;
    color: var(--text-primary);
}

/* ===== Citation Formatting ===== */
.results-content sup,
#researchContent sup {
    color: var(--primary-color);
    font-weight: 600;
    margin: 0 2px;
    font-size: 0.75em;
}

#researchContent h2 {
    margin-top: 24px;
    margin-bottom: 12px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color);
}

#researchContent ul,
#researchContent ol {
    margin-left: 20px;
    margin-bottom: 16px;
}

#researchContent li {
    margin-bottom: 8px;
}

#researchContent a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

#researchContent a:hover {
    border-bottom-color: var(--primary-color);
}

/* ===== Refinement Section ===== */
.refinement-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 2px solid var(--border-color);
}

.refinement-header {
    margin-bottom: 24px;
}

.refinement-header h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.refinement-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Quick Actions */
.quick-actions {
    margin-bottom: 24px;
}

.quick-actions-category {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
}

.quick-actions-category:last-of-type {
    margin-bottom: 0;
}

.quick-actions-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.quick-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.quick-action-btn:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.qa-icon {
    font-size: 1.2rem;
}

.qa-text {
    flex: 1;
}

/* Quick Action Context */
.quick-action-context {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 2px solid var(--primary-color);
}

.quick-action-context label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.quick-action-context textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    margin-bottom: 12px;
}

.quick-action-context-buttons {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Refinement Divider */
.refinement-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.refinement-divider::before,
.refinement-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.refinement-divider span {
    padding: 0 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Custom Question */
.custom-question {
    margin-bottom: 24px;
}

.custom-question-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
}

.question-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hint-tag {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.hint-tag:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.custom-question label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

#refinementQuestion {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: var(--transition);
}

#refinementQuestion:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#refinementBtn {
    margin-top: 12px;
}

/* Conversation History */
.conversation-history {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--border-color);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.conversation-header h4 {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.btn-text-only {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 12px;
    font-size: 0.9rem;
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.btn-text-only:hover {
    background: var(--bg-secondary);
    color: var(--error-color);
}

.conversation-thread {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 8px;
    scroll-behavior: smooth;
    position: relative;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    padding: 16px;
    margin: -16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Hover state - zeigt dass der Bereich scrollbar ist */
.conversation-thread:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    cursor: default;
}

/* Focus state für Keyboard-Navigation */
.conversation-thread:focus-within {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Fade-out Gradient am unteren Rand wenn mehr Inhalt verfügbar */
.conversation-thread::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, var(--bg-primary));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.conversation-thread.has-more-content::after {
    opacity: 1;
}

/* Scroll Progress Indicator für conversation-thread */
.conversation-scroll-indicator {
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.conversation-thread:hover .conversation-scroll-indicator,
.conversation-thread:focus-within .conversation-scroll-indicator {
    opacity: 1;
}

.conversation-scroll-indicator-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    width: 0%;
    transition: width 0.1s ease;
    border-radius: 2px;
}

/* Scrollbar styling for conversation-thread */
.conversation-thread::-webkit-scrollbar {
    width: 10px;
}

.conversation-thread::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 5px;
}

.conversation-thread::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
    transition: background 0.2s ease;
}

.conversation-thread::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

.conversation-item {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.conversation-item.collapsed .conversation-answer {
    display: none;
}

.conversation-question {
    display: flex;
    align-items: start;
    gap: 12px;
    margin-bottom: 16px;
}

.conversation-question-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.conversation-question-content {
    flex: 1;
}

.conversation-question-text {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.conversation-timestamp {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.conversation-answer {
    padding-left: 40px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.conversation-answer h1,
.conversation-answer h2,
.conversation-answer h3 {
    color: var(--text-primary);
    margin-top: 16px;
    margin-bottom: 8px;
}

.conversation-answer ul,
.conversation-answer ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.conversation-answer li {
    margin-bottom: 6px;
}

.conversation-answer code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.conversation-answer pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 12px 0;
}

.conversation-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.conversation-action-btn {
    padding: 6px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    color: var(--text-secondary);
}

.conversation-action-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Loading State für Refinement */
.refinement-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-top: 16px;
}

.refinement-loading .spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .conversation-answer {
        padding-left: 0;
    }
    
    .conversation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .quick-actions-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Reading Progress Bar ===== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color) 0%, #10b981 100%);
    z-index: 9998;
    transition: width 0.1s ease;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* ===== Back to Top Button ===== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: var(--transition);
    z-index: 1000;
}

.back-to-top:hover {
    background: var(--primary-hover);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top:active {
    transform: translateY(-1px);
}

.back-to-top.visible {
    display: flex;
}

/* ===== Scroll to Bottom Button ===== */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    animation: slideUpBtn 0.3s ease-out;
}

.scroll-to-bottom-btn:hover {
    background: var(--primary-hover);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

.scroll-to-bottom-btn:active {
    transform: translateX(-50%) translateY(0);
}

@keyframes slideUpBtn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== Table of Contents ===== */
.toc-container {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    animation: slideIn 0.4s ease-out;
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    cursor: pointer;
    user-select: none;
}

.toc-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-toggle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.toc-container.collapsed .toc-toggle::before {
    content: '▶';
}

.toc-container:not(.collapsed) .toc-toggle::before {
    content: '▼';
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-container.collapsed .toc-list {
    display: none;
}

.toc-item {
    margin-bottom: 8px;
}

.toc-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 0.9375rem;
    line-height: 1.4;
}

.toc-link:hover {
    background: var(--bg-primary);
    color: var(--primary-color);
    transform: translateX(4px);
}

.toc-link.active {
    background: var(--bg-primary);
    color: var(--primary-color);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}

.toc-item-h1 .toc-link {
    padding: 10px 12px;
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(99, 102, 241, 0.05) 100%);
    border-left: 4px solid var(--primary-color);
    margin-bottom: 8px;
}

.toc-item-h1 .toc-link:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.08) 100%);
    transform: translateX(2px);
}

.toc-h1-icon {
    font-size: 1.1rem;
}

.toc-item-h2 .toc-link {
    padding-left: 12px;
    font-weight: 500;
}

.toc-item-h3 .toc-link {
    padding-left: 28px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.toc-item-h3 .toc-link:hover {
    color: var(--primary-color);
}

/* ===== Collapsible Sections ===== */
.section-collapsible {
    margin: 24px 0;
    border-left: 3px solid var(--primary-color);
    padding-left: 16px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
    transition: var(--transition);
}

.section-header:hover {
    color: var(--primary-color);
}

.section-toggle-icon {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.section-collapsible.collapsed .section-toggle-icon {
    transform: rotate(-90deg);
}

.section-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.section-collapsible.collapsed .section-content {
    max-height: 0;
    opacity: 0;
}

.section-collapsible:not(.collapsed) .section-content {
    max-height: none;
    opacity: 1;
}

/* Section controls */
.section-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    flex-wrap: wrap;
}

.section-control-btn {
    padding: 6px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-control-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ===== Responsive Navigation ===== */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .toc-container {
        padding: 16px;
    }
    
    .toc-item-h3 .toc-link {
        padding-left: 24px;
        font-size: 0.8125rem;
    }
    
    .section-controls {
        flex-direction: column;
    }
    
    .section-control-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .reading-progress {
        height: 2px;
    }
    
    .back-to-top {
        width: 40px;
        height: 40px;
        font-size: 18px;
        bottom: 12px;
        right: 12px;
    }
    
    .toc-title {
        font-size: 1rem;
    }
    
    .toc-link {
        font-size: 0.875rem;
    }
    
    .section-collapsible {
        padding-left: 12px;
        border-left-width: 2px;
    }
}

/* ===== Sessions Sidebar ===== */
.sessions-sidebar {
    position: fixed;
    top: 0;
    left: -380px;
    width: 380px;
    height: 100vh;
    background: var(--bg-primary);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sessions-sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 20px;
    margin: 0;
}

.close-sidebar-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    line-height: 1;
}

.close-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.sidebar-notice {
    padding: 16px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    margin: 16px;
    border-radius: var(--border-radius);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.notice-icon {
    font-size: 20px;
    flex-shrink: 0;
}

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

.notice-text strong {
    font-size: 14px;
    color: var(--text-primary);
}

.notice-text small {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.sidebar-storage-info {
    padding: 0 16px 16px;
    flex-shrink: 0;
}

.storage-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.storage-text {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.storage-limit {
    color: var(--text-tertiary);
}

.sidebar-search {
    padding: 0 16px 16px;
    flex-shrink: 0;
}

.sidebar-search input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.sidebar-actions {
    padding: 0 16px 16px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.sidebar-action-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.sidebar-action-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--secondary-color);
}

.sidebar-action-btn.danger:hover {
    background: #fee;
    border-color: var(--error-color);
    color: var(--error-color);
}

.sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state small {
    font-size: 13px;
    line-height: 1.5;
}

.session-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.session-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.session-card.active {
    border-color: var(--primary-color);
    background: #eef2ff;
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.session-date {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.session-actions {
    display: flex;
    gap: 4px;
}

.session-action-btn {
    background: transparent;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: var(--transition);
    opacity: 0.6;
}

.session-action-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

.session-action-btn.delete:hover {
    background: #fee;
    color: var(--error-color);
}

.session-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.session-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.session-badge {
    font-size: 11px;
    padding: 3px 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
}

.toggle-sidebar-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9997;
    background: white;
    border: 2px solid var(--border-color);
    padding: 10px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.toggle-sidebar-btn:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.session-count {
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Hidden file input for import */
#importFileInput {
    display: none;
}

/* ===== Print Styles ===== */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .header,
    .input-section,
    .mode-section,
    .action-section,
    .research-section,
    .refinement-section,
    .footer,
    .back-to-top,
    .reading-progress,
    .section-controls,
    .sessions-sidebar,
    .sidebar-overlay,
    .toggle-sidebar-btn {
        display: none;
    }

    .results-section {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
    
    .toc-container {
        border: 1px solid var(--border-color);
        background: white;
    }
    
    .section-collapsible {
        border-left: 2px solid var(--border-color);
    }
    
    .section-collapsible.collapsed .section-content {
        max-height: none;
        opacity: 1;
        display: block;
    }
}

/* ===== Responsive Sidebar ===== */
@media (max-width: 768px) {
    .sessions-sidebar {
        width: 100%;
        left: -100%;
    }
    
    .toggle-sidebar-btn {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
        font-size: 13px;
    }
}
