:root {
    --bg: #ffffff;
    --card: #f5f7fa;
    --text: #1f2d3a;
    --muted: #6b7280;
    --historical: #1f77b4;
    --cone-inner: rgba(100,150,220,0.25);
    --cone-outer: rgba(200,200,200,0.2);
    --radius: 10px;
    --shadow: 0 18px 40px -12px rgba(0,0,0,0.08);
    font-family: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
    
    /* Risk pulse colors */
    --risk-high: #e74c3c;
    --risk-medium-high: #e67e22;
    --risk-medium: #f1c40f;
    --risk-low-medium: #2ecc71;
    --risk-low: #27ae60;
}
* { box-sizing:border-box; }
body { background: var(--bg); color: var(--text); }
h1 { margin-top:0; font-size:1.75rem; font-weight:600; }
.card {
    background: var(--card);
    padding:1.25rem 1.5rem;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    max-width:960px;
    margin:1rem auto;
}
.subtitle { font-size:0.9rem; color: var(--muted); margin:4px 0 12px; }
.legend { display:flex; gap:1.25rem; align-items:center; font-size:12px; margin-bottom:8px; }
.legend-item { display:flex; align-items:center; gap:6px; }
.legend-line { width:18px; height:4px; display:inline-block; border-radius:2px; }
.tooltip {
    position:absolute;
    pointer-events:none;
    background:#ffffff;
    padding:10px 14px;
    border-radius:6px;
    font-size:12px;
    box-shadow:0 20px 50px rgba(0,0,0,0.08);
    border:1px solid #d1d9e6;
    color: var(--text);
    line-height:1.3;
}
.axis text { font-size:10px; fill: var(--muted); }
.axis path, .axis line { stroke: #d9e2ef; }

/* Risk Pulse Gauge Styling */
.risk-pulse-card {
    margin-top: 1rem;
    max-width: 400px;
}

.risk-pulse-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.risk-pulse-header {
    width: 100%;
}

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

.risk-pulse-header h2 {
    margin-bottom: 12px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

.risk-pulse-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.gauge-wrapper {
    position: relative;
    width: 144px;
    height: 78px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 30px;
}

.gauge-text {
    position: absolute;
    bottom: -30px;
    width: 100%;
    text-align: center;
}

.gauge-text-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#gauge-value {
    font-size: 28px;
    font-weight: 700;
    color: #1f2d3a;
}

#gauge-label {
    display: block;
    font-size: 14px;
    color: #6b7280;
    margin-top: 2px;
}

/* Remove old fear and greed styling */
.fear-greed-card {
    display: none;
}

/* Risk Pulse Chart Styling */
.risk-pulse-chart-card {
    margin-top: 1rem;
}

#risk-pulse-chart .bar:hover {
    cursor: pointer;
}

#risk-pulse-chart .axis text {
    font-size: 10px;
    fill: var(--muted);
}

#risk-pulse-chart .axis path,
#risk-pulse-chart .axis line {
    stroke: #d9e2ef;
}

/* Card row layout */
.cards-row {
    display: flex;
    gap: 1rem;
    margin: 1rem auto;
    max-width: 960px;
    flex-wrap: wrap;
}

.cards-row .card {
    flex: 1;
    min-width: 280px;
    margin: 0;
}

/* Change cards styling */
.change-card {
    text-align: center;
    overflow: visible; /* overrides .card { overflow: hidden; } */
}

.change-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px 0;
}

.change-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 8px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
}

.change-value.positive {
    color: var(--risk-low);
}

.change-value.negative {
    color: var(--risk-high);
}

.change-label {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 4px;
}

/* Portfolio Holdings Table */
.holdings-table {
    overflow-x: auto;
    margin-top: 1rem;
}

.portfolio-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.portfolio-table th {
    background: rgba(31, 45, 58, 0.05);
    color: var(--text);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 2px solid rgba(31, 45, 58, 0.1);
}

.portfolio-table th:nth-child(2),
.portfolio-table th:nth-child(3) {
    text-align: right;
}

.portfolio-table td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(31, 45, 58, 0.08);
    color: var(--text);
}

.portfolio-table tr:hover {
    background: rgba(31, 45, 58, 0.02);
}

.portfolio-table .token-name {
    font-weight: 600;
    color: var(--text);
}

.portfolio-table .quantity {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    text-align: right;
}

.portfolio-table .value {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    text-align: right;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .cards-row {
        flex-direction: column;
    }

    .cards-row .card {
        min-width: unset;
    }

    .change-value {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .change-value {
        font-size: 1.5rem;
    }
}

/* Explanations / helper tooltips */
.heading-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.explain {
    position: relative;
    display: inline-flex;
}

.explain-icon {
    width: 20px;
    height: 20px;
    border: 1px solid #d1d9e6;
    background: #ffffff;
    color: var(--muted);
    border-radius: 50%;
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.explain-icon:hover,
.explain-icon:focus {
    color: var(--text);
    border-color: #cbd5e1;
    outline: none;
}

.explain-box {
    position: absolute;
    z-index: 9999;
    top: calc(100% + 8px);
    left: 0;
    background: #ffffff;
    border: 1px solid #d1d9e6;
    border-radius: 8px;
    padding: 10px 12px;
    width: min(320px, 80vw);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.explain:hover .explain-box,
.explain:focus-within .explain-box {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.explain-box::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 12px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #d1d9e6 transparent;
}

.explain-box::after {
    content: "";
    position: absolute;
    top: -5px;
    left: 13px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent #ffffff transparent;
}

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

.explain-text {
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.35;
}

.explain-text p {
    margin: 6px 0;
}

.explain-note {
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
    margin-top: 6px;
}

/* Optional: align Risk Pulse header content horizontally */
.risk-pulse-header .heading-row h2 {
    margin: 0;
}

/* Fix: ensure tooltip content is left-aligned even inside centered cards */
.explain-box,
.explain-box .explain-title,
.explain-box .explain-text,
.explain-box .explain-text p,
.explain-box .explain-note {
    text-align: left;
}

/* Glowing attention animation for explain icon */
@keyframes explain-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(31, 119, 180, 0);
        color: var(--muted);
        border-color: #d1d9e6;
        background: #ffffff;
    }
    50% {
        box-shadow: 0 0 0 6px rgba(31, 119, 180, 0.15), 0 2px 10px rgba(31, 119, 180, 0.18);
        color: var(--historical);
        border-color: var(--historical);
        background: #ffffff;
    }
}

/* Apply glow by default (subtle) */
.explain-icon {
    animation: explain-glow 2.2s ease-in-out infinite;
    will-change: box-shadow, color, border-color;
}

/* Stronger, steady state on hover/focus and pause animation */
.explain-icon:hover,
.explain-icon:focus {
    color: var(--historical);
    border-color: var(--historical);
    box-shadow: 0 0 0 8px rgba(31, 119, 180, 0.18), 0 6px 16px rgba(31, 119, 180, 0.22);
    animation: none;
    outline: none;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .explain-icon {
        animation: none;
        box-shadow: none;
    }
}

/* Mobile-safe tooltip: prevent off-screen overflow on small viewports */
@media (max-width: 600px) {
    .explain {
        position: static; /* avoid positioning constraints from inline containers */
    }
    .explain-box {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 12px);
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        max-height: 50vh;           /* ensure content stays within the viewport */
        overflow: auto;             /* scroll if content is taller */
        transform: none;            /* no translate on mobile */
        z-index: 10000;             /* stay above other UI */
    }
    .explain-box::before,
    .explain-box::after {
        display: none;              /* hide arrow in overlay mode */
    }
}
/* Title + CTA row */
.title-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    max-width: 960px;
    margin: 0.5rem auto 0.5rem;
}

.title-cta .page-title {
    margin: 0;
    flex: 1 1 auto;
    text-align: center;
}

.masked-input {
    font-family: text-security-disc;
    /*-webkit-text-security: disc;*/
    -moz-text-security: disc;
    text-security: disc;
}

/* Primary CTA button aligned with site palette */
.cta-analyze {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 9999px;
    background: var(--historical);
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    border: 1px solid rgba(31, 119, 180, 0.35);
    box-shadow: 0 10px 24px rgba(31, 119, 180, 0.25);
    transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.cta-analyze:hover,
.cta-analyze:focus {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(31, 119, 180, 0.34);
    outline: none;
}

.cta-analyze:active {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(31, 119, 180, 0.25);
}

/* Stack button under title on small screens */
@media (max-width: 600px) {
    .title-cta {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
    .cta-analyze {
        width: 100%;
        max-width: 320px;
        text-align: center;
    }
}