/* ===================================================================
   pm-trader Dashboard -- Dark Trading Theme
   =================================================================== */

/* -- Reset & Base --------------------------------------------------- */

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

:root {
    --bg-primary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1a2745;
    --bg-input: #0f1a30;
    --accent: #0f3460;
    --highlight: #e94560;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-heading: #ffffff;
    --pnl-positive: #4ade80;
    --pnl-negative: #e94560;
    --border: #2a2a4a;
    --nav-bg: #0f0f23;
    --radius: 8px;
    --radius-sm: 4px;
}

html {
    font-size: 14px;
    line-height: 1.5;
}

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

a {
    color: #53c1de;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}


/* -- Navbar --------------------------------------------------------- */

.navbar {
    background-color: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: 0.5px;
}

.nav-brand a:hover {
    text-decoration: none;
    color: var(--highlight);
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: var(--accent);
    color: var(--text-heading);
    text-decoration: none;
}

.nav-link.active {
    background: var(--accent);
    color: var(--text-heading);
}


/* -- Layout --------------------------------------------------------- */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
    width: 100%;
}

.footer {
    text-align: center;
    padding: 16px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
}


/* -- Typography ----------------------------------------------------- */

.page-title {
    font-size: 1.75rem;
    color: var(--text-heading);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.2rem;
    color: var(--text-heading);
    margin: 28px 0 14px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 28px 0 14px;
}

.section-header .section-title {
    margin: 0;
}

.page-header {
    margin-bottom: 20px;
}

.back-link {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 8px;
}

.back-link:hover {
    color: var(--text-primary);
}

.last-activity {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
    margin-bottom: 8px;
}


/* -- Cards ---------------------------------------------------------- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin: 20px 0;
}

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

.card-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
}


/* -- Module grid ---------------------------------------------------- */

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.module-card {
    display: block;
    transition: border-color 0.15s, background 0.15s;
}

.module-card:hover {
    border-color: var(--highlight);
    background: var(--bg-card-hover);
}

.module-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.module-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.module-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-heading);
}

.module-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.module-stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}


/* -- Chart card ----------------------------------------------------- */

.chart-card {
    padding: 20px;
    margin-bottom: 16px;
}


/* -- Tables --------------------------------------------------------- */

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.cell-market {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-date {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
}


/* -- Badges --------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Budget mode badges */
.badge-active {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

.badge-cautious {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
}

.badge-hibernate {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
}

.badge-unknown {
    background: rgba(160, 160, 160, 0.15);
    color: #a0a0a0;
}

/* Trading mode badges */
.badge-paper {
    background: rgba(249, 115, 22, 0.25);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

.badge-live {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.4);
}

.module-badges {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Side badges */
.badge-side-yes {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

.badge-side-no {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
}

/* Position status badges */
.badge-status-open {
    background: rgba(83, 193, 222, 0.15);
    color: #53c1de;
}

.badge-status-closing {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
}

.badge-status-closed {
    background: rgba(160, 160, 160, 0.15);
    color: #a0a0a0;
}

.badge-status-stopped {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
}

/* Thesis status badges */
.badge-thesis-pending {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
}

.badge-thesis-claimed {
    background: rgba(83, 193, 222, 0.15);
    color: #53c1de;
}

.badge-thesis-executed {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

.badge-thesis-rejected {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
}

.badge-thesis-expired {
    background: rgba(160, 160, 160, 0.15);
    color: #a0a0a0;
}


/* -- P&L colors ----------------------------------------------------- */

.pnl-positive {
    color: var(--pnl-positive) !important;
}

.pnl-negative {
    color: var(--pnl-negative) !important;
}


/* -- Thesis cards --------------------------------------------------- */

.thesis-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thesis-card {
    padding: 16px 20px;
}

.thesis-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.thesis-question {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    flex: 1;
}

.thesis-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.thesis-checks {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.check-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.check-passed {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

.check-failed {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
}

.thesis-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.thesis-id {
    font-family: monospace;
    opacity: 0.6;
}

/* Confidence coloring */
.confidence-7 { color: #facc15; }
.confidence-8 { color: #f97316; }
.confidence-9 { color: #ef4444; }
.confidence-10 { color: #dc2626; font-weight: 700; }


/* -- Episode cards -------------------------------------------------- */

.episode-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.episode-card {
    padding: 16px 20px;
}

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

.badge-episode {
    font-size: 0.7rem;
    padding: 3px 8px;
}

/* Episode type colors */
.badge-episode-trade-opened      { background: rgba(83, 193, 222, 0.15); color: #53c1de; }
.badge-episode-trade-closed      { background: rgba(160, 160, 160, 0.15); color: #a0a0a0; }
.badge-episode-win-pattern       { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.badge-episode-loss-event        { background: rgba(233, 69, 96, 0.15); color: #e94560; }
.badge-episode-risk-trigger      { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.badge-episode-capital-recycle   { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.badge-episode-lesson-learned    { background: rgba(250, 204, 21, 0.15); color: #facc15; }
.badge-episode-position-review   { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }

.importance-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--highlight);
    margin-right: 2px;
}

.episode-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 6px;
}

.episode-content {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.episode-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}


/* -- Health page ---------------------------------------------------- */

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.health-stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
}

.health-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-heading);
    flex-shrink: 0;
}

.health-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-heading);
}

.health-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-healthy {
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.status-unhealthy {
    background: #e94560;
    box-shadow: 0 0 6px rgba(233, 69, 96, 0.5);
}


/* -- Buttons -------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}

.btn-secondary {
    background: var(--accent);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #143d70;
    text-decoration: none;
}


/* -- Empty state ---------------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 1.1rem;
}


/* -- Service status grid ------------------------------------------- */

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.service-card {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.service-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.service-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-heading);
}

.service-status {
    font-size: 0.75rem;
    margin-left: 18px;
}

.service-up {
    color: var(--text-secondary);
}

.service-down {
    color: var(--pnl-negative);
}


/* -- Traders page -------------------------------------------------- */

.traders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.trader-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.trader-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trader-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-heading);
}

.trader-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.trader-stat {
    display: flex;
    flex-direction: column;
}

.trader-actions {
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.btn-stop {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
    padding: 6px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(233, 69, 96, 0.3);
    transition: background 0.15s;
}

.btn-stop:hover {
    background: rgba(233, 69, 96, 0.3);
}

.btn-stop:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sell {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
    padding: 4px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(233, 69, 96, 0.3);
    transition: background 0.15s;
}

.btn-sell:hover {
    background: rgba(233, 69, 96, 0.3);
}

.btn-sell:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-start {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    padding: 6px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(74, 222, 128, 0.3);
    transition: background 0.15s;
}

.btn-start:hover {
    background: rgba(74, 222, 128, 0.3);
}

.btn-start:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 3px 12px;
    font-size: 0.75rem;
}

.service-actions {
    margin-top: 4px;
    margin-left: 18px;
}

.service-card-actions {
    margin-top: 4px;
    margin-left: 18px;
}


/* -- Exploration page ----------------------------------------------- */

.module-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.container-status {
    font-size: 0.75rem;
}

.btn-icon {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-icon:hover {
    background: var(--accent);
    color: var(--text-heading);
    border-color: var(--accent);
    text-decoration: none;
}

.module-params-panel {
    border-top: 1px solid var(--border);
    padding: 10px 0 4px;
    margin-top: 10px;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 12px;
}

.param-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}

.param-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.param-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace;
}

#pcaChart {
    width: 100% !important;
}

/* -- Responsive ----------------------------------------------------- */

@media (max-width: 768px) {
    .navbar {
        padding: 0 12px;
    }

    .nav-links {
        gap: 4px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .container {
        padding: 16px;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .module-grid {
        grid-template-columns: 1fr;
    }

    .module-card-body {
        grid-template-columns: 1fr 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

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

    .nav-brand a {
        font-size: 1rem;
    }
}


/* -- Pipeline page ------------------------------------------------- */

.pipeline-page {
    max-width: 960px;
    margin: 0 auto;
}

.pipeline-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.pipeline-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.pipeline-select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.9rem;
    min-width: 200px;
}

.pipeline-select:focus {
    outline: 1px solid var(--highlight);
    border-color: var(--highlight);
}

.pipeline-config-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pipeline-config-status.status-loaded {
    color: var(--pnl-positive);
}

.pipeline-config-status.status-offline {
    color: var(--pnl-negative);
}


/* -- Flowchart layout --------------------------------------------- */

.flowchart {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.flow-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.stage-label {
    background: var(--accent);
    color: var(--text-heading);
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}


/* -- Flow rows: node + config side by side ----------------------- */

.flow-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    align-items: start;
}

.flow-node {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.flow-node:hover {
    border-color: #53c1de;
    box-shadow: 0 0 12px rgba(83, 193, 222, 0.15);
}

.node-icon {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.node-gate .node-icon {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}

.node-llm .node-icon {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.node-execute .node-icon {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.node-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.node-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}


/* -- Config panels (right side) ---------------------------------- */

.flow-config-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-left: 3px solid var(--accent);
}

.cfg-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}

.cfg-key {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cfg-val {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace;
    transition: color 0.3s, background 0.3s;
    padding: 0 4px;
    border-radius: 3px;
}

.cfg-flash {
    color: #53c1de !important;
    background: rgba(83, 193, 222, 0.15);
}


/* -- Trade decision explainer ------------------------------------ */

.flow-explainer {
    margin: 12px auto 16px;
    max-width: 700px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    border-left: 3px solid #a855f7;
}

.explainer-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #a855f7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.explainer-scores {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

.explainer-score {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px;
    border-radius: var(--radius);
    background: rgba(168, 85, 247, 0.06);
    border: 1px solid rgba(168, 85, 247, 0.15);
}

.explainer-score-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-heading);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.explainer-score-range {
    font-size: 0.75rem;
    font-weight: 600;
    color: #a855f7;
    font-family: monospace;
}

.explainer-score-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.explainer-example {
    margin-bottom: 12px;
}

.explainer-example-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.explainer-table {
    width: 100%;
    font-size: 0.78rem;
    border-collapse: collapse;
}

.explainer-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
}

.explainer-table td {
    padding: 4px 8px;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.78rem;
}

.explainer-table tr:not(:last-child) td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.text-green  { color: #4ade80; font-weight: 600; font-family: inherit; }
.text-yellow { color: #facc15; font-weight: 600; font-family: inherit; }
.text-red    { color: #f87171; font-weight: 600; font-family: inherit; }

.explainer-why-range {
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.explainer-why-range p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

@media (max-width: 600px) {
    .explainer-scores { grid-template-columns: 1fr; }
}


/* -- Connectors between nodes ------------------------------------ */

.flow-connector {
    display: flex;
    justify-content: center;
    padding: 4px 0;
    width: 50%;
}

.flow-line {
    width: 2px;
    height: 28px;
    background: linear-gradient(180deg, var(--border), rgba(83, 193, 222, 0.3), var(--border));
    position: relative;
    overflow: hidden;
}

.flow-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #53c1de;
    box-shadow: 0 0 8px rgba(83, 193, 222, 0.8), 0 0 16px rgba(83, 193, 222, 0.4);
    left: 50%;
    transform: translateX(-50%);
    animation: flowDown 2.4s ease-in-out infinite;
}

@keyframes flowDown {
    0% { top: -6px; opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* Stagger particles across the pipeline for a continuous flow feel */
.flow-stage:nth-child(1) .flow-row:nth-child(2) .flow-particle { animation-delay: 0s; }
.flow-stage:nth-child(1) .flow-connector:nth-child(3) .flow-particle { animation-delay: 0.3s; }
.flow-stage:nth-child(1) .flow-connector:nth-child(5) .flow-particle { animation-delay: 0.6s; }
.flow-stage:nth-child(1) .flow-connector:nth-child(7) .flow-particle { animation-delay: 0.9s; }
.flow-stage:nth-child(1) .flow-connector:nth-child(9) .flow-particle { animation-delay: 1.2s; }
.flow-stage:nth-child(1) .flow-connector:nth-child(11) .flow-particle { animation-delay: 1.5s; }
.flow-stage:nth-child(1) .flow-connector:nth-child(13) .flow-particle { animation-delay: 1.8s; }
.flow-stage:nth-child(3) .flow-connector:nth-child(3) .flow-particle { animation-delay: 2.4s; }
.flow-stage:nth-child(3) .flow-connector:nth-child(5) .flow-particle { animation-delay: 2.7s; }
.flow-stage:nth-child(3) .flow-connector:nth-child(7) .flow-particle { animation-delay: 3.0s; }


/* -- Service boundary -------------------------------------------- */

.flow-boundary {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.flow-boundary-line {
    flex: 1;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        var(--highlight) 0,
        var(--highlight) 8px,
        transparent 8px,
        transparent 16px
    );
    opacity: 0.5;
}

.flow-boundary-label {
    background: var(--bg-primary);
    color: var(--highlight);
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 16px;
    border: 1px solid var(--highlight);
    border-radius: 20px;
    white-space: nowrap;
}

.boundary-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    top: 50%;
    transform: translateY(-50%);
    animation: flowAcross 3s linear infinite;
}

@keyframes flowAcross {
    0% { left: -10px; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}


/* -- Exit pipeline ----------------------------------------------- */

.exit-stage {
    margin-top: 8px;
}

.exit-chain {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.exit-node {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 12px;
    align-items: center;
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.exit-node:hover {
    box-shadow: 0 0 12px rgba(83, 193, 222, 0.1);
}

.exit-hard { border-left: 3px solid var(--pnl-negative); }
.exit-soft { border-left: 3px solid #facc15; }
.exit-emergency { border-left: 3px solid #ef4444; }

.exit-priority {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-heading);
    text-align: center;
    font-family: monospace;
}

.exit-name {
    font-weight: 600;
    color: var(--text-heading);
    font-size: 0.9rem;
}

.exit-detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.exit-detail span[id] {
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace;
    transition: color 0.3s, background 0.3s;
    padding: 0 3px;
    border-radius: 3px;
}

.exit-sub-detail {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.3;
}

.exit-sub-detail .exit-sub-label {
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 4px;
}

.exit-sub-detail span[id] {
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace;
    transition: color 0.3s, background 0.3s;
    padding: 0 3px;
    border-radius: 3px;
}

.exit-compact {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
}

.exit-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.badge-ungated {
    background: rgba(233, 69, 96, 0.15);
    color: #e94560;
}

.badge-gated {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
}

.badge-info {
    background: rgba(83, 193, 222, 0.15);
    color: #53c1de;
}

.exit-connector {
    height: 16px;
    width: 2px;
    background: linear-gradient(180deg, var(--border), rgba(233, 69, 96, 0.3), var(--border));
    position: relative;
    overflow: hidden;
}

.exit-particle {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #e94560;
    box-shadow: 0 0 6px rgba(233, 69, 96, 0.7);
    left: 50%;
    transform: translateX(-50%);
    animation: flowDown 2s ease-in-out infinite;
}

/* Stagger exit particles */
.exit-chain .exit-connector:nth-child(2) .exit-particle { animation-delay: 0s; }
.exit-chain .exit-connector:nth-child(4) .exit-particle { animation-delay: 0.25s; }
.exit-chain .exit-connector:nth-child(6) .exit-particle { animation-delay: 0.5s; }
.exit-chain .exit-connector:nth-child(8) .exit-particle { animation-delay: 0.75s; }
.exit-chain .exit-connector:nth-child(10) .exit-particle { animation-delay: 1.0s; }
.exit-chain .exit-connector:nth-child(12) .exit-particle { animation-delay: 1.25s; }
.exit-chain .exit-connector:nth-child(14) .exit-particle { animation-delay: 1.5s; }
.exit-chain .exit-connector:nth-child(16) .exit-particle { animation-delay: 1.75s; }


/* -- Terminal states --------------------------------------------- */

.flow-terminals {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.terminal-node {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid;
}

.t-closed   { background: rgba(160,160,160,0.12); color: #a0a0a0; border-color: rgba(160,160,160,0.3); }
.t-stopped  { background: rgba(233,69,96,0.12);   color: #e94560; border-color: rgba(233,69,96,0.3); }
.t-resolved { background: rgba(83,193,222,0.12);  color: #53c1de; border-color: rgba(83,193,222,0.3); }
.t-expired  { background: rgba(250,204,21,0.12);  color: #facc15; border-color: rgba(250,204,21,0.3); }
.t-redeemed { background: rgba(74,222,128,0.12);  color: #4ade80; border-color: rgba(74,222,128,0.3); }


/* -- Pipeline footer --------------------------------------------- */

.pipeline-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.pipeline-credit {
    font-style: italic;
    opacity: 0.6;
}


/* -- Pipeline responsive ----------------------------------------- */

@media (max-width: 768px) {
    .flow-row {
        grid-template-columns: 1fr;
    }

    .flow-connector {
        width: 100%;
    }

    .exit-node {
        grid-template-columns: 32px 1fr auto;
    }

    .pipeline-controls {
        flex-wrap: wrap;
    }
}


/* -- Self-Reflection page ---------------------------------------- */

.reflection-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.reflection-card {
    padding: 20px 24px;
}

.reflection-card-stats {
    padding: 16px 20px;
}

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

.badge-reflection-llm {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.badge-reflection-stats {
    background: rgba(83, 193, 222, 0.15);
    color: #53c1de;
}

.reflection-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.reflection-summary {
    font-size: 1.05rem;
    color: var(--text-heading);
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.5;
}

.reflection-section {
    margin-bottom: 14px;
}

.reflection-section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.reflection-section-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.reflection-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 4px;
}

@media (max-width: 768px) {
    .reflection-columns {
        grid-template-columns: 1fr;
    }
}

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

.reflection-list-items li {
    font-size: 0.88rem;
    color: var(--text-primary);
    padding: 4px 0 4px 16px;
    position: relative;
    line-height: 1.4;
}

.reflection-list-items li::before {
    content: "+";
    position: absolute;
    left: 0;
    color: var(--pnl-positive);
    font-weight: 700;
}

.reflection-list-negative li::before {
    content: "-";
    color: var(--pnl-negative);
}

.proposal-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.proposal-item {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    border-left: 3px solid #a855f7;
}

.proposal-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.proposal-rationale {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.proposal-impact {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-style: italic;
}

.reflection-raw {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
}

.reflection-stats-content {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
    font-family: monospace;
    background: var(--bg-input);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}


/* ===================================================================
   Claude Mascot -- Animated tentacle buddy
   =================================================================== */

.claude-mascot {
    display: flex;
    align-items: center;
    margin-right: 8px;
    cursor: default;
}

.claude-svg {
    overflow: visible;
    animation: claude-float 3s ease-in-out infinite;
}

/* -- Base shapes -------------------------------------------------- */

.claude-body {
    fill: #d4a574;
    stroke: #c4956a;
    stroke-width: 1;
}

.claude-glow {
    fill: none;
    stroke: rgba(168, 85, 247, 0.0);
    stroke-width: 2;
    transition: stroke 0.5s;
}

.claude-eye {
    fill: #2d1b0e;
}

.claude-pupil {
    fill: #fff;
    opacity: 0;
}

.claude-mouth {
    fill: none;
    stroke: #2d1b0e;
    stroke-width: 1.5;
    stroke-linecap: round;
    transition: d 0.3s;
}

.claude-tentacle {
    fill: none;
    stroke: #c4956a;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.claude-sparkle {
    fill: #facc15;
    opacity: 0;
}


/* -- Idle float animation ---------------------------------------- */

@keyframes claude-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}


/* -- Tentacle wave (shared base) --------------------------------- */

.claude-tentacle {
    animation: tentacle-wave 2.5s ease-in-out infinite;
    transform-origin: top center;
}
.t1 { animation-delay: 0s; }
.t2 { animation-delay: 0.15s; }
.t3 { animation-delay: 0.3s; }
.t4 { animation-delay: 0.45s; }
.t5 { animation-delay: 0.6s; }

@keyframes tentacle-wave {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(3deg); }
    75%      { transform: rotate(-3deg); }
}


/* ===================================================================
   Mood: Happy (Overview) -- default, gentle glow + smile
   =================================================================== */

.mood-happy .claude-glow {
    stroke: rgba(74, 222, 128, 0.25);
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { stroke: rgba(74, 222, 128, 0.1); }
    50%      { stroke: rgba(74, 222, 128, 0.35); }
}


/* ===================================================================
   Mood: Thinking (Research) -- eyes look up, slow float
   =================================================================== */

.mood-thinking .claude-svg {
    animation: claude-float 4s ease-in-out infinite;
}

.mood-thinking .claude-eye-l { cy: 21; }
.mood-thinking .claude-eye-r { cy: 21; }

.mood-thinking .claude-pupil {
    opacity: 1;
    animation: pupil-wander 3s ease-in-out infinite;
}
.mood-thinking .claude-pupil-l { cx: 24; cy: 21; }
.mood-thinking .claude-pupil-r { cx: 38; cy: 21; }

@keyframes pupil-wander {
    0%, 100% { transform: translateX(0); }
    30%      { transform: translateX(1.5px); }
    70%      { transform: translateX(-1px); }
}

.mood-thinking .claude-mouth {
    d: path("M29,30 Q32,31 35,30");
}

.mood-thinking .claude-tentacle {
    animation: tentacle-curl 4s ease-in-out infinite;
}

@keyframes tentacle-curl {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-5deg) scaleY(0.92); }
}


/* ===================================================================
   Mood: Dreaming (Memory) -- eyes closed (lines), slow breathing
   =================================================================== */

.mood-dreaming .claude-svg {
    animation: claude-float 5s ease-in-out infinite;
}

.mood-dreaming .claude-eye {
    ry: 0.5;
    rx: 2.5;
}

.mood-dreaming .claude-body {
    animation: dream-breathe 4s ease-in-out infinite;
}

@keyframes dream-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.03); }
}

.mood-dreaming .claude-mouth {
    d: path("M29,30 Q32,33 35,30");
}

.mood-dreaming .claude-glow {
    stroke: rgba(83, 193, 222, 0.2);
    animation: dream-glow 4s ease-in-out infinite;
}

@keyframes dream-glow {
    0%, 100% { stroke: rgba(83, 193, 222, 0.1); stroke-width: 2; }
    50%      { stroke: rgba(83, 193, 222, 0.3); stroke-width: 3; }
}

.mood-dreaming .claude-tentacle {
    animation: tentacle-wave 5s ease-in-out infinite;
}


/* ===================================================================
   Mood: Reflecting (Reflection) -- sparkles + self-aware glow
   =================================================================== */

.mood-reflecting .claude-glow {
    stroke: rgba(168, 85, 247, 0.3);
    animation: reflect-glow 3s ease-in-out infinite;
}

@keyframes reflect-glow {
    0%, 100% { stroke: rgba(168, 85, 247, 0.15); }
    50%      { stroke: rgba(168, 85, 247, 0.45); }
}

.mood-reflecting .claude-sparkle {
    opacity: 1;
    animation: sparkle-blink 2s ease-in-out infinite;
}

.mood-reflecting .s1 { animation-delay: 0s; }
.mood-reflecting .s2 { animation-delay: 0.7s; }
.mood-reflecting .s3 { animation-delay: 1.4s; }

@keyframes sparkle-blink {
    0%, 100% { opacity: 0; transform: scale(0.5); }
    50%      { opacity: 1; transform: scale(1.2); }
}

.mood-reflecting .claude-pupil {
    opacity: 1;
    fill: #facc15;
}
.mood-reflecting .claude-pupil-l { cx: 25; cy: 23; r: 1.2; }
.mood-reflecting .claude-pupil-r { cx: 39; cy: 23; r: 1.2; }


/* ===================================================================
   Mood: Dizzy (Debug) -- spinning eyes, wobbly body
   =================================================================== */

.mood-dizzy .claude-svg {
    animation: claude-wobble 2s ease-in-out infinite;
}

@keyframes claude-wobble {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25%      { transform: translateY(-2px) rotate(2deg); }
    50%      { transform: translateY(0) rotate(0deg); }
    75%      { transform: translateY(-2px) rotate(-2deg); }
}

.mood-dizzy .claude-eye {
    animation: eye-spin 1.5s linear infinite;
    transform-origin: center;
}

@keyframes eye-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mood-dizzy .claude-pupil {
    opacity: 1;
    fill: #e94560;
}
.mood-dizzy .claude-pupil-l { cx: 25; cy: 22; }
.mood-dizzy .claude-pupil-r { cx: 39; cy: 22; }

.mood-dizzy .claude-mouth {
    d: path("M28,31 Q32,29 36,31");
}

.mood-dizzy .claude-glow {
    stroke: rgba(233, 69, 96, 0.2);
}


/* ===================================================================
   Mood: Busy (Pipeline) -- fast tentacle wave, active glow
   =================================================================== */

.mood-busy .claude-svg {
    animation: claude-float 1.5s ease-in-out infinite;
}

.mood-busy .claude-tentacle {
    animation: tentacle-flail 0.8s ease-in-out infinite;
}

@keyframes tentacle-flail {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(8deg); }
    75%      { transform: rotate(-8deg); }
}

.mood-busy .claude-glow {
    stroke: rgba(83, 193, 222, 0.3);
    animation: busy-glow 1s ease-in-out infinite;
}

@keyframes busy-glow {
    0%, 100% { stroke: rgba(83, 193, 222, 0.15); }
    50%      { stroke: rgba(83, 193, 222, 0.4); }
}

.mood-busy .claude-pupil {
    opacity: 1;
    animation: pupil-dart 0.6s ease-in-out infinite;
}
.mood-busy .claude-pupil-l { cx: 25.5; }
.mood-busy .claude-pupil-r { cx: 39.5; }

@keyframes pupil-dart {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(1px); }
}


/* ===================================================================
   Mood: Healthy (Health) -- green glow, content smile
   =================================================================== */

.mood-healthy .claude-glow {
    stroke: rgba(74, 222, 128, 0.3);
    animation: glow-pulse 2.5s ease-in-out infinite;
}

.mood-healthy .claude-body {
    fill: #d4a574;
    animation: healthy-pulse 3s ease-in-out infinite;
}

@keyframes healthy-pulse {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.1); }
}


/* ===================================================================
   Mood: Curious (Exploration) -- wide eyes, perky tentacles
   =================================================================== */

.mood-curious .claude-eye-l { r: 3; }
.mood-curious .claude-eye-r { r: 3; }

.mood-curious .claude-pupil {
    opacity: 1;
    fill: #fff;
    r: 1.2;
}

.mood-curious .claude-svg {
    animation: claude-peek 3s ease-in-out infinite;
}

@keyframes claude-peek {
    0%, 100% { transform: translateY(0) translateX(0); }
    30%      { transform: translateY(-3px) translateX(2px); }
    70%      { transform: translateY(-1px) translateX(-2px); }
}

.mood-curious .claude-tentacle {
    animation: tentacle-perk 2s ease-in-out infinite;
}

@keyframes tentacle-perk {
    0%, 100% { transform: rotate(0deg) scaleY(1); }
    50%      { transform: rotate(2deg) scaleY(0.9); }
}

.mood-curious .claude-glow {
    stroke: rgba(250, 204, 21, 0.2);
    animation: curious-glow 2s ease-in-out infinite;
}

@keyframes curious-glow {
    0%, 100% { stroke: rgba(250, 204, 21, 0.1); }
    50%      { stroke: rgba(250, 204, 21, 0.35); }
}


/* -- Hover interaction ------------------------------------------- */

.claude-mascot:hover .claude-svg {
    animation: claude-bounce 0.4s ease-out;
}

@keyframes claude-bounce {
    0%   { transform: translateY(0) scale(1); }
    40%  { transform: translateY(-6px) scale(1.1); }
    70%  { transform: translateY(-2px) scale(1.05); }
    100% { transform: translateY(0) scale(1); }
}

.claude-mascot:hover .claude-tentacle {
    animation: tentacle-flail 0.6s ease-in-out 2;
}


/* ===================================================================
   Living Mascot — JS-driven data-reactive moods + behaviors
   =================================================================== */

/* -- Data moods (set by mascot.js, prefix data-mood-*) ------------ */

.data-mood-euphoric .claude-glow {
    stroke: rgba(250, 204, 21, 0.4) !important;
}
.data-mood-winning .claude-glow {
    stroke: rgba(74, 222, 128, 0.35) !important;
}
.data-mood-calm .claude-glow {
    stroke: rgba(168, 85, 247, 0.2) !important;
}
.data-mood-nervous .claude-glow {
    stroke: rgba(251, 146, 60, 0.3) !important;
}
.data-mood-panicking .claude-glow {
    stroke: rgba(239, 68, 68, 0.35) !important;
}
.data-mood-sleeping .claude-glow {
    stroke: rgba(99, 102, 241, 0.15) !important;
}


/* -- Shiver animation (nervous/panicking) ------------------------- */

@keyframes mascot-shiver {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-0.5px); }
    75%      { transform: translateX(0.5px); }
}


/* -- Flinch on page click ----------------------------------------- */

@keyframes mascot-flinch {
    0%   { transform: scale(1) translateY(0); }
    30%  { transform: scale(0.92) translateY(1px); }
    100% { transform: scale(1) translateY(0); }
}


/* -- Backflip on double-click ------------------------------------- */

.mascot-backflip {
    animation: mascot-do-backflip 0.8s ease-in-out !important;
}

@keyframes mascot-do-backflip {
    0%   { transform: rotate(0deg) scale(1); }
    25%  { transform: rotate(0deg) scale(1.2) translateY(-15px); }
    50%  { transform: rotate(180deg) scale(1.1) translateY(-20px); }
    75%  { transform: rotate(360deg) scale(1.05) translateY(-8px); }
    100% { transform: rotate(360deg) scale(1) translateY(0); }
}


/* -- Ink screen overlay (right-click) ----------------------------- */

.mascot-ink-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    background: radial-gradient(circle at 50% 30%, rgba(45, 27, 14, 0.85) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.15s;
}

.mascot-ink-active {
    opacity: 1;
}

.mascot-ink-fade {
    opacity: 0;
    transition: opacity 0.6s;
}


/* -- Speech bubble ------------------------------------------------ */

.mascot-speech {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%) scale(0.5);
    background: var(--bg-card, #1e293b);
    color: var(--text-primary, #e2e8f0);
    border: 1px solid var(--border-color, #334155);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-family: inherit;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
}

.mascot-speech::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-color, #334155);
}

@keyframes speech-pop {
    0%   { opacity: 0; transform: translateX(-50%) scale(0.5) translateY(5px); }
    100% { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
}

@keyframes speech-fade {
    0%   { opacity: 1; transform: translateX(-50%) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) scale(0.8) translateY(5px); }
}


/* -- ZzZ floating letters (sleep) --------------------------------- */

.mascot-zzz {
    position: absolute;
    top: -8px;
    font-size: 12px;
    font-weight: 700;
    color: rgba(165, 180, 252, 0.8);
    pointer-events: none;
    animation: zzz-float 3s ease-out forwards;
}

@keyframes zzz-float {
    0%   { opacity: 0.9; transform: translateY(0) rotate(0deg) scale(0.7); }
    50%  { opacity: 0.7; transform: translateY(-18px) rotate(-15deg) scale(1); }
    100% { opacity: 0; transform: translateY(-35px) rotate(10deg) scale(1.2); }
}


/* -- Holding on during scroll ------------------------------------- */

.mascot-holding-on .claude-svg {
    animation: mascot-grip 0.3s ease-in-out !important;
}

.mascot-holding-on .claude-tentacle {
    animation: none !important;
    transform: rotate(0deg) scaleY(0.85);
}

@keyframes mascot-grip {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(3deg) translateX(2px); }
}


/* -- Stolen cursor (cursor steal easter egg) ------------------------ */

.mascot-stolen-cursor {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    transition: left 0.25s ease-in-out, top 0.25s ease-in-out, opacity 0.3s;
}


/* ================================================================
   Review & Position Detail additions
   ================================================================ */

/* -- Review action badges ---------------------------------------- */
.badge-review-hold       { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-review-sell       { background: rgba(233, 69, 96, 0.15);  color: #e94560; }
.badge-review-take_profit { background: rgba(74, 222, 128, 0.15); color: #4ade80; }

/* -- Confidence badges (1-5) ------------------------------------- */
.badge-confidence-1 { background: rgba(160, 160, 160, 0.15); color: #a0a0a0; }
.badge-confidence-2 { background: rgba(233, 69, 96, 0.15);   color: #e94560; }
.badge-confidence-3 { background: rgba(250, 204, 21, 0.15);  color: #facc15; }
.badge-confidence-4 { background: rgba(59, 130, 246, 0.15);  color: #3b82f6; }
.badge-confidence-5 { background: rgba(74, 222, 128, 0.15);  color: #4ade80; }

/* -- Review timeline --------------------------------------------- */
.review-timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.review-entry {
    padding: 12px 16px;
    border-left: 3px solid var(--accent);
}

.review-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.review-reasoning {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
}

/* -- Price staleness warning -------------------------------------- */
.stale-price-icon {
    color: #f97316;
    font-size: 0.85rem;
    cursor: help;
}

/* -- Position detail grid ---------------------------------------- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    padding: 16px 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* -- Clickable market links in tables ----------------------------- */
.cell-market a {
    color: var(--text-heading);
    text-decoration: none;
}

.cell-market a:hover {
    color: #53c1de;
    text-decoration: underline;
}

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