:root {
    /* Content area — warm cream */
    --bg: #f0ebe3;
    --surface: #e8e1d6;
    --surface-hover: #ddd6ca;
    --border: #d0c9be;
    --text: #2c2826;
    --text-dim: #8a8078;
    --accent: #6b8a6b;
    --accent-hover: #5a7a5a;
    --accent-dim: #4a6a4a;
    --success: #5a9e5a;
    --warning: #c08a30;
    --error: #c05050;
    --info: #5070b0;

    /* Sidebar — warm dark */
    --sidebar-bg: #2a2726;
    --sidebar-surface: #353130;
    --sidebar-border: #4a4543;
    --sidebar-text: #a8a098;
    --sidebar-text-active: #8aad7a;
    --sidebar-active-bg: rgba(138, 173, 122, 0.1);
    --sidebar-active-dot: #c8a850;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    padding: 1.5rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 0.5rem 1rem 1.5rem;
}

.sidebar-logo {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    min-height: 44px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.nav-link:hover {
    color: #d0c8c0;
    background: var(--sidebar-surface);
}

.nav-link.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-active-bg);
    border-right: 2px solid var(--sidebar-text-active);
}

.nav-link.active .nav-icon {
    color: var(--sidebar-active-dot);
}

.nav-icon {
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    text-align: center;
}
.nav-icon-search { font-size: 1.5rem; }
.nav-icon-log { font-size: 1.1rem; }
.nav-icon-diamond { font-size: 0.85rem; }

/* Main content */
.content {
    margin-left: 220px;
    flex: 1;
    padding: 2rem;
    min-width: 0;
}

/* Page header */
.page-header {
    margin-bottom: 2rem;
}

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

.page-header p {
    color: var(--text-dim);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.chart-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

.data-table tr:hover td {
    background: var(--surface-hover);
}

.data-table a {
    color: var(--accent);
    text-decoration: none;
}

.data-table a:hover {
    color: var(--accent-hover);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-insight { background: rgba(90, 140, 90, 0.12); color: #4a7a4a; }
.badge-decision { background: rgba(100, 80, 150, 0.10); color: #6a5a9a; }
.badge-error { background: rgba(192, 80, 80, 0.10); color: #a04040; }
.badge-pattern { background: rgba(192, 138, 48, 0.12); color: #8a6a20; }
.badge-question { background: rgba(80, 112, 176, 0.10); color: #405a8a; }
.badge-milestone { background: rgba(60, 120, 140, 0.10); color: #3a7a8a; }
.badge-skill { background: rgba(90, 140, 90, 0.12); color: #4a7a4a; }
.badge-semantic { background: rgba(90, 140, 90, 0.12); color: #4a7a4a; }
.badge-grep { background: rgba(192, 138, 48, 0.12); color: #8a6a20; }

/* Signals panel */
.signal-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.signal-panel h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.signal-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    padding: 0.25rem 0;
}

.signal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.signal-dot.active { background: var(--success); }
.signal-dot.inactive { background: var(--text-dim); }

/* Search */
.search-box {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.search-input {
    flex: 1;
    padding: 0.625rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
}

.btn {
    padding: 0.625rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
}

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

/* Search results */
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
}

.result-score {
    font-weight: 700;
    color: var(--accent);
}

.result-date { color: var(--text-dim); }

.result-content {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text);
}

/* Log entries */
.log-entry {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.log-entry-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.log-entry-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.log-entry-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.log-entry-body {
    font-size: 0.8125rem;
    line-height: 1.6;
}

/* Filters bar */
.filters-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-select {
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.8125rem;
}

/* Trend indicators */
.trend-up { color: var(--success); }
.trend-down { color: var(--error); }
.trend-flat { color: var(--text-dim); }

/* Effectiveness bar */
.eff-bar {
    width: 80px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.eff-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* Timeline */
.timeline {
    border-left: 2px solid var(--border);
    padding-left: 1.5rem;
    margin-left: 0.5rem;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.25rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.75rem;
    top: 0.25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.timeline-text {
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* Section header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

/* Detail page */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}

/* Personality: User & Agent panels */
.persona-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.persona-panel {
    border-radius: 10px;
    padding: 1.5rem;
    border-top: 3px solid transparent;
}

.persona-panel--user {
    background: #dce8dc;
    border: 1px solid #b5ccb5;
    border-top: 3px solid #6b8a6b;
}

.persona-panel--agent {
    background: #dae1ed;
    border: 1px solid #b0bed8;
    border-top: 3px solid #5070b0;
}

.persona-panel__header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.25rem;
}

.persona-panel__icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    line-height: 1;
    color: #fff;
    flex-shrink: 0;
}

.persona-panel--user .persona-panel__icon {
    background: #6b8a6b;
}

.persona-panel--agent .persona-panel__icon {
    background: #5070b0;
}

.persona-panel__title {
    font-size: 1rem;
    font-weight: 700;
}

.persona-panel__desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.persona-section {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    padding: 0.75rem 0.875rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.persona-section__label {
    font-size: 0.6875rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
    font-weight: 600;
}

.persona-section__content {
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre-line;
}

/* Log list */
.log-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
}

.log-list-item:hover {
    background: var(--surface-hover);
}

.compact-badge {
    font-size: 0.6875rem;
    color: var(--text-dim);
    background: var(--border);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-dim);
}

/* HTMX indicator */
.htmx-indicator {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--text-dim);
    z-index: 100;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
}

/* Chart descriptions */
.chart-desc { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.75rem; }

/* Language switch */
.lang-switch { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid var(--sidebar-border); display: flex; gap: 0.5rem; }
.lang-btn { padding: 0.5rem 0.75rem; min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; font-size: 0.75rem; color: var(--sidebar-text); text-decoration: none; transition: all 0.15s; }
.lang-btn:hover { color: #d0c8c0; background: var(--sidebar-surface); }
.lang-btn.active { color: var(--sidebar-text-active); background: var(--sidebar-active-bg); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; max-width: 720px; width: 90%; max-height: 85vh; overflow-y: auto; padding: 1.5rem; }
.modal-close { float: right; background: none; border: none; color: var(--text-dim); font-size: 1.25rem; cursor: pointer; padding: 0.25rem; }
.modal-close:hover { color: var(--text); }

/* Log overview */
.log-overview { font-size: 0.8125rem; color: var(--text-dim); margin-top: 0.25rem; line-height: 1.5; }

/* Section title */
.section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 0.75rem; font-weight: 600; }

/* Card sections */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2.5rem;
}

.card h2 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    letter-spacing: 0.01em;
}

/* Stat row (horizontal stat cards) */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

/* Alert */
.alert { padding: 0.75rem 1rem; border-radius: 6px; font-size: 0.875rem; margin-bottom: 1rem; }
.alert-warning { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); color: var(--warning); }

/* Section description */
.section-desc {
    font-size: 0.8125rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Signal status labels */
.status-ready {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(90, 158, 90, 0.12);
    color: #3a7a3a;
}

.status-accumulating {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(139, 143, 154, 0.15);
    color: var(--text-dim);
}

/* Principles list */
.principles-list { display: flex; flex-direction: column; gap: 1.25rem; }
.principle-item h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text); }
.principle-item p { font-size: 0.8125rem; line-height: 1.6; color: var(--text-dim); }
.principle-item ul { font-size: 0.8125rem; line-height: 1.6; color: var(--text-dim); padding-left: 1.25rem; margin-top: 0.25rem; }
.principle-item li { margin-bottom: 0.25rem; }
.principle-item code { font-size: 0.8125rem; background: var(--border); padding: 0.125rem 0.375rem; border-radius: 3px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 60px; padding: 1rem 0; }
    .sidebar-brand { display: none; }
    .nav-link span:not(.nav-icon) { display: none; }
    .nav-link { justify-content: center; padding: 0.75rem; }
    .content { margin-left: 60px; padding: 1rem; }
    .charts-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .persona-grid { grid-template-columns: 1fr; }
}
