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

:root {
    --bg: #0a0e1a;
    --bg-card: #141a2b;
    --bg-input: #0f1422;
    --border: #25304a;
    --text: #e8ecf5;
    --text-dim: #8090b0;
    --accent: #4ea8ff;
    --accent-glow: rgba(78, 168, 255, 0.15);
    --accent-hover: #66b5ff;
    --gold: #f5c54b;
    --success: #4ade80;
    --danger: #f87171;
    --radius: 12px;
    --radius-sm: 8px;
    --max-w: 720px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    background-image:
        radial-gradient(circle at 20% 10%, rgba(78, 168, 255, 0.08), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(245, 197, 75, 0.05), transparent 40%);
    background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Home Page ===== */
.hero {
    text-align: center;
    padding: 80px 20px 40px;
}
.hero-icon {
    font-size: 56px;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 20px var(--accent-glow));
}
.hero h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero .subtitle {
    color: var(--text);
    font-size: 18px;
    margin-bottom: 6px;
    opacity: 0.9;
}
.hero p {
    color: var(--text-dim);
    font-size: 15px;
    max-width: 520px;
    margin: 0 auto 32px;
    line-height: 1.75;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 8px 24px var(--accent-glow); }
.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 20px;
    max-width: var(--max-w);
    margin: 0 auto 40px;
}
.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: all 0.3s;
}
.feature-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.feature-card .icon { font-size: 28px; margin-bottom: 12px; }
.feature-card h3 { font-size: 16px; margin-bottom: 6px; color: var(--gold); }
.feature-card p { font-size: 13px; color: var(--text-dim); }

.disclaimer {
    max-width: var(--max-w);
    margin: 0 auto 40px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-left: 20px;
}

.report-list {
    max-width: var(--max-w);
    margin: 0 auto 40px;
    padding: 0 20px;
}
.report-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.report-item:hover { border-color: var(--accent); }
.report-item .name { font-weight: 500; }
.report-item .date { font-size: 13px; color: var(--text-dim); }

/* ===== Chat Page ===== */
.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: var(--max-w);
    margin: 0 auto;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.chat-header .back { font-size: 20px; cursor: pointer; }
.chat-header h2 { font-size: 18px; font-weight: 600; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 20px;
    max-width: 85%;
}
.message.assistant { margin-right: auto; }
.message.user { margin-left: auto; }

.message .bubble {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}
.message.assistant .bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
}
.message.user .bubble {
    background: var(--accent);
    color: white;
}

.message .role-label {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 4px;
    padding: 0 4px;
}

.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-row textarea {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 12px 16px;
    font-size: 15px;
    font-family: var(--font);
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input-row textarea:focus { border-color: var(--accent); }
.chat-input-row textarea::placeholder { color: var(--text-dim); }

.send-btn {
    width: 44px;
    height: 44px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.mic-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.mic-btn:hover { border-color: var(--accent); }
.mic-btn.mic-active {
    background: var(--danger);
    border-color: var(--danger);
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(248,113,113,0); }
}

.report-prompt {
    padding: 12px 20px;
    background: var(--accent-glow);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}
.report-prompt .hint { font-size: 14px; color: var(--text-dim); }

/* ===== Report Page ===== */
.report-page {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 40px 20px;
}

.report-page .report-header {
    text-align: center;
    margin-bottom: 32px;
}
.report-page .report-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.report-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    line-height: 1.8;
    font-size: 15px;
}

.report-content h1, .report-content h2, .report-content h3 {
    margin-top: 28px;
    margin-bottom: 12px;
}
.report-content h1 { font-size: 22px; }
.report-content h2 { font-size: 19px; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.report-content h3 { font-size: 16px; color: var(--gold); }
.report-content p { margin-bottom: 12px; }
.report-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-dim);
    font-style: italic;
}
.report-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}
.report-content th, .report-content td {
    border: 1px solid var(--border);
    padding: 10px 12px;
    text-align: left;
}
.report-content th { background: var(--bg); font-weight: 600; color: var(--gold); }
.report-content ul, .report-content ol { padding-left: 24px; margin-bottom: 12px; }
.report-content li { margin-bottom: 4px; }
.report-content strong { color: var(--gold); }
.report-content hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.report-content code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.report-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
    flex-wrap: wrap;
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}
.loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--success);
    color: var(--text);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 1000;
    animation: fadeInUp 0.3s;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 600px) {
    .hero { padding: 48px 16px 24px; }
    .hero h1 { font-size: 28px; }
    .chat-messages { padding: 16px; }
    .message { max-width: 92%; }
    .report-content { padding: 20px; }
    .features { grid-template-columns: 1fr; }
}
