/* ============================================================
   Fear & Greed Index 日本版 - Light Theme (CNN Style)
   ============================================================ */

:root {
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #333333;
    --text-muted: #666666;
    --text-dim: #999999;
    --border: #e0e0e0;
    --border-light: #f0f0f0;

    /* Sentiment colors (CNN-style) */
    --extreme-fear: #b71c1c;
    --fear: #e65100;
    --neutral: #757575;
    --greed: #2e7d32;
    --extreme-greed: #1b5e20;

    --extreme-fear-bg: #ffebee;
    --fear-bg: #fff3e0;
    --neutral-bg: #f5f5f5;
    --greed-bg: #e8f5e9;
    --extreme-greed-bg: #e8f5e9;

    --header-height: 48px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
   Header
   ============================================================ */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #1a1a2e;
    color: #fff;
    height: var(--header-height);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-text {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.logo-jp {
    color: #93c5fd;
    font-weight: 600;
    font-size: 0.8rem;
}

.ticker-bar {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ticker-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.ticker-name {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.ticker-value {
    color: #fff;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ticker-change {
    font-weight: 600;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.ticker-change.up {
    color: #4ade80;
}

.ticker-change.down {
    color: #f87171;
}

/* ============================================================
   Hero
   ============================================================ */

.hero {
    padding: 40px 24px 24px;
    border-bottom: 1px solid var(--border);
}

.hero-inner {
    max-width: 980px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 48px;
}

.hero-left {
    flex: 0 0 auto;
    text-align: center;
}

.hero-title {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    color: var(--text);
}

.gauge-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#gauge-canvas {
    max-width: 100%;
    height: auto;
}

.gauge-info {
    position: absolute;
    bottom: 20px;
    text-align: center;
}

.gauge-label {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.gauge-score {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.last-updated {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-top: 4px;
}

.hero-right {
    flex: 1;
    padding-top: 8px;
}

.hero-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.7;
}

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

.score-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.score-history-item:last-child {
    border-bottom: none;
}

.score-history-period {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.score-history-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.score-history-value {
    font-size: 1.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
}

.score-history-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 3px;
    min-width: 80px;
    text-align: center;
}

/* ============================================================
   Tabs
   ============================================================ */

.tabs-container {
    border-bottom: 2px solid var(--border);
    background: var(--bg);
}

.tabs {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 0;
}

.tab {
    padding: 14px 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s ease;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--text);
    border-bottom-color: #1a1a2e;
}

/* ============================================================
   Tab Content
   ============================================================ */

.tab-content {
    display: none;
    padding: 32px 0;
}

.tab-content.active {
    display: block;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 24px;
    color: var(--text);
}

/* ============================================================
   Indicators (CNN Style)
   ============================================================ */

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

.indicator-section {
    padding: 32px 0;
    border-bottom: 1px solid var(--border);
}

.indicator-section:last-child {
    border-bottom: none;
}

.indicator-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

.indicator-title-group {
    flex: 1;
}

.indicator-name {
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text);
    margin-bottom: 2px;
}

.indicator-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 400;
}

.indicator-badge {
    padding: 4px 12px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    border: 2px solid;
    flex-shrink: 0;
    margin-left: 16px;
}

.indicator-content {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.indicator-chart-side {
    flex: 3;
    min-width: 0;
}

.indicator-chart-container {
    height: 220px;
    position: relative;
}

.indicator-last-updated {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 6px;
}

.indicator-text-side {
    flex: 2;
}

.indicator-description {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.indicator-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.detail-item {
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.78rem;
    border: 1px solid var(--border-light);
}

.detail-label {
    color: var(--text-dim);
    margin-right: 4px;
}

.detail-value {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* No-chart layout: for indicators without chart data */
.indicator-no-chart .indicator-content {
    flex-direction: column;
    gap: 12px;
}

/* ============================================================
   Timeline
   ============================================================ */

.timeline-chart-container {
    background: var(--bg);
}

.chart-wrapper {
    height: 350px;
    position: relative;
}

/* ============================================================
   FAQ
   ============================================================ */

.faq-section {
    padding: 48px 0 64px;
    border-top: 1px solid var(--border);
}

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

.faq-item {
    border-bottom: 1px solid var(--border);
}

.faq-item:first-child {
    border-top: 1px solid var(--border);
}

.faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.faq-toggle {
    font-size: 1.3rem;
    font-weight: 300;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: 16px;
}

.faq-item.open .faq-toggle {
    transform: rotate(45deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-answer p,
.faq-answer ol,
.faq-answer ul,
.faq-answer table {
    padding: 0 0 0 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.8;
}

.faq-answer p:last-child,
.faq-answer ol:last-child,
.faq-answer ul:last-child,
.faq-answer table:last-child {
    padding-bottom: 16px;
}

.faq-answer ol,
.faq-answer ul {
    padding-left: 20px;
}

.faq-answer strong {
    color: var(--text);
}

.score-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.score-table th,
.score-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.score-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
}

.score-table .extreme-fear {
    color: var(--extreme-fear);
    font-weight: 700;
}

.score-table .fear {
    color: var(--fear);
    font-weight: 700;
}

.score-table .neutral {
    color: var(--neutral);
    font-weight: 700;
}

.score-table .greed {
    color: var(--greed);
    font-weight: 700;
}

.score-table .extreme-greed {
    color: var(--extreme-greed);
    font-weight: 700;
}

.disclaimer {
    font-style: italic;
    font-size: 0.8rem !important;
    color: var(--text-dim) !important;
    margin-top: 8px;
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
    padding: 24px 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    background: var(--bg-secondary);
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.footer-disclaimer {
    color: var(--text-dim);
    font-size: 0.72rem;
}

/* ============================================================
   Sentiment Color Utilities
   ============================================================ */

.sentiment-extreme-fear {
    color: var(--extreme-fear) !important;
}

.sentiment-fear {
    color: var(--fear) !important;
}

.sentiment-neutral {
    color: var(--neutral) !important;
}

.sentiment-greed {
    color: var(--greed) !important;
}

.sentiment-extreme-greed {
    color: var(--extreme-greed) !important;
}

.badge-extreme-fear {
    border-color: var(--extreme-fear);
    color: var(--extreme-fear);
    background: var(--extreme-fear-bg);
}

.badge-fear {
    border-color: var(--fear);
    color: var(--fear);
    background: var(--fear-bg);
}

.badge-neutral {
    border-color: var(--neutral);
    color: var(--neutral);
    background: var(--neutral-bg);
}

.badge-greed {
    border-color: var(--greed);
    color: var(--greed);
    background: var(--greed-bg);
}

.badge-extreme-greed {
    border-color: var(--extreme-greed);
    color: var(--extreme-greed);
    background: var(--extreme-greed-bg);
}

.label-bg-extreme-fear {
    background: var(--extreme-fear-bg);
    color: var(--extreme-fear);
}

.label-bg-fear {
    background: var(--fear-bg);
    color: var(--fear);
}

.label-bg-neutral {
    background: var(--neutral-bg);
    color: var(--neutral);
}

.label-bg-greed {
    background: var(--greed-bg);
    color: var(--greed);
}

.label-bg-extreme-greed {
    background: var(--extreme-greed-bg);
    color: var(--extreme-greed);
}

/* ============================================================
   Responsive - Tablet
   ============================================================ */

@media (max-width: 768px) {
    .header-inner {
        padding: 0 16px;
    }

    .hero {
        padding: 24px 16px;
    }

    .hero-inner {
        flex-direction: column;
        gap: 24px;
        align-items: center;
    }

    .hero-left {
        width: 100%;
    }

    .hero-right {
        width: 100%;
    }

    .score-history-value {
        font-size: 1.2rem;
    }

    .indicator-content {
        flex-direction: column;
        gap: 16px;
    }

    .indicator-chart-container {
        height: 200px;
    }

    .chart-wrapper {
        height: 280px;
    }

    .tabs {
        padding: 0 16px;
    }

    .container {
        padding: 0 16px;
    }
}

/* ============================================================
   Responsive - Mobile
   ============================================================ */

@media (max-width: 480px) {
    .header-inner {
        flex-direction: column;
        height: auto;
        padding: 8px 12px;
        gap: 4px;
    }

    .header {
        height: auto;
    }

    .logo-text {
        font-size: 0.82rem;
    }

    .ticker-bar {
        gap: 10px;
    }

    .ticker-item {
        font-size: 0.72rem;
        gap: 4px;
    }

    .hero-title {
        font-size: 1.2rem;
    }

    .gauge-container {
        transform: scale(0.82);
        transform-origin: center top;
    }

    .gauge-score {
        font-size: 2.8rem;
    }

    .gauge-label {
        font-size: 0.9rem;
    }

    .tabs {
        padding: 0 12px;
    }

    .tab {
        padding: 12px 16px;
        font-size: 0.82rem;
    }

    .indicator-name {
        font-size: 0.88rem;
    }

    .indicator-badge {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    .indicator-chart-container {
        height: 180px;
    }

    .chart-wrapper {
        height: 220px;
    }

    .section-title {
        font-size: 0.95rem;
    }

    .faq-question {
        font-size: 0.88rem;
    }
}

/* ============================================================
   Next Update Display
   ============================================================ */

.next-updated {
    color: var(--text-dim);
    font-size: 0.72rem;
    margin-top: 2px;
}

/* ============================================================
   Error Panel
   ============================================================ */

.error-panel {
    background: #fff3f3;
    border: 1px solid #e53935;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    margin: 16px 0;
}

.error-panel-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.error-panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: #c62828;
    margin-bottom: 4px;
}

.error-panel-message {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 16px;
}

.error-panel-retry {
    display: inline-block;
    padding: 8px 24px;
    border: 2px solid #1a1a2e;
    border-radius: 4px;
    background: #1a1a2e;
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.error-panel-retry:hover {
    opacity: 0.85;
}

/* ============================================================
   Dark Mode
   ============================================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f0f1a;
        --bg-secondary: #1a1a2e;
        --bg-card: #1e1e32;
        --text: #e8e8f0;
        --text-secondary: #c0c0d0;
        --text-muted: #8888a0;
        --text-dim: #606078;
        --border: #2a2a40;
        --border-light: #222238;

        /* Sentiment colors stay vibrant on dark */
        --extreme-fear-bg: rgba(183, 28, 28, 0.15);
        --fear-bg: rgba(230, 81, 0, 0.15);
        --neutral-bg: rgba(117, 117, 117, 0.12);
        --greed-bg: rgba(46, 125, 50, 0.15);
        --extreme-greed-bg: rgba(27, 94, 32, 0.15);
    }

    body {
        background: var(--bg);
        color: var(--text);
    }

    .header {
        background: #0a0a18;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    }

    .footer {
        background: var(--bg-secondary);
        border-top-color: var(--border);
    }

    .tabs-container {
        background: var(--bg);
        border-bottom-color: var(--border);
    }

    .tab.active {
        border-bottom-color: #93c5fd;
    }

    .hero {
        border-bottom-color: var(--border);
    }

    .faq-section {
        border-top-color: var(--border);
    }

    .faq-item {
        border-bottom-color: var(--border);
    }

    .faq-item:first-child {
        border-top-color: var(--border);
    }

    .score-table th,
    .score-table td {
        border-bottom-color: var(--border);
    }

    .timeline-chart-container {
        background: var(--bg);
    }

    .detail-item {
        background: var(--bg-secondary);
        border-color: var(--border);
    }

    .error-panel {
        background: rgba(183, 28, 28, 0.12);
        border-color: #e53935;
    }

    .error-panel-title {
        color: #ef5350;
    }

    .error-panel-message {
        color: var(--text-muted);
    }

    .error-panel-retry {
        background: #93c5fd;
        border-color: #93c5fd;
        color: #0a0a18;
    }
}