:root {
    --brand: #4a63e7;
    --brand-dark: #3a4fc7;
    --ink: #222;
    --muted: #666;
    --bg: #f7f8fb;
    --white: #fff;
    --ok: #1f9852;
    --warn: #b08400;
    --danger: #d32f2f;
    --border: #e8e8ef;
    --shadow: rgba(0,0,0,0.1);
}

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 4px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--brand);
    text-decoration: none;
}

.logo img {
    height: 32px;
}

.nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav a {
    color: var(--ink);
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 500;
}

.nav a:hover {
    color: var(--brand);
}

.nav a.active {
    color: var(--brand);
    border-bottom: 2px solid var(--brand);
    padding-bottom: 2px;
}

.main {
    flex: 1;
    width: 100%;
}

.main .wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.footer .wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.banner {
    background: #fff6db;
    border: 1px solid #ffe28a;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    color: #5a4a00;
    margin-bottom: 2rem;
}

.banner strong {
    color: #3a3000;
}

.banner a {
    color: var(--brand);
    font-weight: 500;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.card h1, .card h2, .card h3 {
    margin-bottom: 1rem;
    color: var(--ink);
}

.card h1 {
    font-size: 2rem;
}

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

.card h3 {
    font-size: 1.25rem;
}

.card p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

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

.grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.hint {
    color: var(--muted);
    font-size: 0.95rem;
    font-style: italic;
    margin-top: 0.5rem;
}

.btn {
    display: inline-block;
    background: var(--brand);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn:hover {
    background: var(--brand-dark);
}

.btn-secondary {
    background: var(--muted);
}

.btn-secondary:hover {
    background: #555;
}

.small {
    font-size: 0.9rem;
    color: var(--muted);
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 2rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

table th, table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: var(--bg);
    font-weight: 600;
}

table tr:hover {
    background: #fafafa;
}

.code-block {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    margin: 1rem 0;
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.chat-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 99, 231, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 1000;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(74, 99, 231, 0.4);
}

.chat-panel {
    position: fixed;
    right: 24px;
    bottom: 100px;
    width: 380px;
    max-width: calc(100vw - 48px);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none;
    overflow: hidden;
    z-index: 999;
}

.chat-panel.active {
    display: block;
    animation: slideUp 0.3s ease-out;
}

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

.chat-header {
    padding: 1rem;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: var(--white);
    font-size: 0.95rem;
}

.chat-header select option {
    background: var(--brand);
}

.chat-header .close-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-header .close-btn:hover {
    opacity: 1;
}

.chat-body {
    padding: 1rem;
    height: 300px;
    overflow-y: auto;
    background: #fafafa;
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
}

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

.chat-message .bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: var(--white);
    box-shadow: 0 1px 2px var(--shadow);
}

.chat-message.user .bubble {
    background: var(--brand);
    color: var(--white);
}

.chat-message .name {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.chat-message.user .name {
    text-align: right;
    color: var(--brand);
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--white);
}

.chat-input input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}

.chat-input input:focus {
    outline: none;
    border-color: var(--brand);
}

.chat-input button {
    padding: 0.75rem 1.25rem;
    background: var(--brand);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.chat-input button:hover {
    background: var(--brand-dark);
}

.internal-header {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    text-align: center;
    color: #856404;
    font-weight: 500;
}

.evidence-item {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    transition: box-shadow 0.2s;
}

.evidence-item:hover {
    box-shadow: 0 4px 12px var(--shadow);
}

.evidence-label {
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .nav {
        flex-wrap: wrap;
        gap: 0.75rem;
        font-size: 0.9rem;
    }
    
    .grid {
        grid-template-columns: 1fr;
    }
    
    .chat-panel {
        width: calc(100vw - 48px);
        right: 24px;
    }
}