:root {
    --bg-color: #f4f4f5;
    --card-bg: #ffffff;
    --text-main: #333333;
    --border-color: #e0e0e0;
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --safety-amber: #ffbf00;
    --safety-bg: #fffbf0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    padding: 2rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 { margin: 0; color: var(--primary-color); }
.subtitle { color: #666; font-style: italic; }

.about-icon {
    font-size: 1.2rem;
    cursor: pointer;
    vertical-align: super;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.about-icon:hover { opacity: 1; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.hidden { display: none !important; }

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

select, input, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1rem;
    background-color: #fafafa;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    font-family: inherit;
}
textarea { resize: vertical; min-height: 100px; }

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.25);
    background-color: #ffffff;
}

.query-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: #eef2f5;
    padding: 0.3rem;
    border-radius: 6px;
}
.q-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: all 0.2s ease;
}
.q-tab-btn.active {
    background: #fff;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    width: 100%;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn:hover { background-color: var(--accent-color); }
.btn:active { transform: scale(0.98); }

.session-id {
    background: #eef2f5;
    padding: 1rem;
    border-radius: 4px;
    font-family: monospace;
    word-break: break-all;
    margin-bottom: 1.5rem;
}

.safety-footer {
    border: 3px solid var(--safety-amber);
    background-color: var(--safety-bg);
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: #997300;
    font-weight: 600;
    border-radius: 4px;
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.tab-btn.active {
    color: var(--primary-color);
    background: #eef2f5;
}

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

.stat-box {
    background: #eef2f5;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.stat-box h3 { margin: 0 0 0.5rem 0; font-size: 0.9rem; color: #666; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary-color); }

/* Auditor Desk Styles */
.auditor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.action-list { list-style: none; padding: 0; margin: 0; }
.action-list li {
    background: #f9fafb;
    border-left: 4px solid var(--accent-color);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-size: 0.95rem;
}
.action-list li.warning { border-left-color: var(--safety-amber); }

.badge {
    background: var(--primary-color);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    vertical-align: middle;
    margin-left: 0.5rem;
}
.badge-warning { background: var(--safety-amber); color: #333; }
.mt-2 { margin-top: 2rem; }

.leaderboard { display: flex; flex-direction: column; gap: 0.5rem; }
.leaderboard-row {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-weight: 600;
}
.leaderboard-row:nth-child(1) { border-color: #ffd700; background: #fffdf0; } /* Gold */
.leaderboard-row:nth-child(2) { border-color: #c0c0c0; background: #f9f9f9; } /* Silver */
.leaderboard-row:nth-child(3) { border-color: #cd7f32; background: #fffaf0; } /* Bronze */

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    display: none;
}
.modal:not(.hidden) {
    display: flex !important;
}
.modal-content {
    position: relative;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    margin: 0;
}
.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    line-height: 1;
}
.close-btn:hover {
    color: #333;
}

/* Testimony Machine UI */
.modal-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 2rem;
}
.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    color: white;
    text-transform: uppercase;
}
.status-answered { background-color: #27ae60; }
.status-unknown { background-color: #95a5a6; }

.btn-small {
    background: #ecf0f1;
    border: 1px solid #bdc3c7;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 10px;
    transition: background-color 0.2s;
}
.btn-small:hover { background: #e0e6ed; }

.expert-only { display: none; }
.expert-mode-active .expert-only { display: block; }

/* Phase 3 Auditor Enhancements */
.decay-bar-container {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin: 0.5rem 0;
    overflow: hidden;
}
.decay-bar {
    height: 100%;
    background: var(--safety-amber);
    transition: width 0.3s ease;
}
.contradiction-item:focus {
    outline: 2px solid var(--accent-color);
    background: #fff;
}
.visual-graph-container {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin-top: 1rem;
    display: flex;
    justify-content: center;
}
.graph-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.graph-level {
    display: flex;
    gap: 1rem;
    justify-content: center;
}
.graph-node {
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
}
.graph-node.center-node {
    border-color: var(--primary-color);
    border-width: 2px;
    background: #eef2f5;
}
.graph-node.derived { border-left: 4px solid #9b59b6; }
.graph-node.corroborates { border-left: 4px solid #27ae60; }
.graph-node.contradicts { border-left: 4px solid #e74c3c; }
.graph-edge {
    color: #999;
    font-weight: bold;
}

/* Tooltips */
.tooltip-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: #bdc3c7;
    color: #fff;
    border-radius: 50%;
    text-align: center;
    line-height: 16px;
    font-size: 11px;
    cursor: help;
    margin-left: 6px;
    position: relative;
    font-weight: bold;
}
.tooltip-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 0.8rem;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.tooltip-icon:hover::before {
    content: "";
    position: absolute;
    bottom: 80%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--primary-color) transparent transparent transparent;
    z-index: 1000;
}

/* First-Time Wizard Styles */
#wizard-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); z-index: 2000;
}
#wizard-dialog {
    position: fixed; z-index: 2002; width: 320px;
    background: #fff; padding: 1.5rem; border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    transition: top 0.3s ease, left 0.3s ease, opacity 0.3s ease;
}
.wizard-highlight {
    position: relative !important;
    z-index: 2001 !important;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.6) !important;
    pointer-events: none; /* Disable interaction during the tour */
}
.wizard-highlight-tabs {
    background: var(--bg-color); /* Fix for nav tab background mismatch */
    border-radius: 8px;
    padding: 1rem;
    margin: -1rem; /* Offset padding to keep layout stable */
}
.wizard-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    align-items: center;
}