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

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: #f5f5f5;
            color: #333;
        }

        header {
            background: white;
            border-bottom: 1px solid #ddd;
            padding: 1.5rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 1.3rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            color: #000;
        }

        .paper-chip {
            font-size: 0.7rem;
            font-weight: 700;
            border-radius: 10px;
            padding: 2px 8px;
            background: #eee;
            color: #666;
            align-self: center;
        }

        .container {
            max-width: 1400px;
            margin: 2rem auto;
            padding: 0 2rem;
        }

        .title-section { margin-bottom: 2rem; }

        .title {
            font-size: 2.2rem;
            font-weight: 700;
            margin-bottom: 0.3rem;
            color: #000;
        }

        .subtitle { color: #666; font-size: 0.95rem; }

        .chart-wrapper {
            background: white;
            border-radius: 8px;
            padding: 2rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            margin-bottom: 2.5rem;
            /* A mis-measured plot must never widen the page */
            overflow: hidden;
        }

        #portfolio-chart { width: 100%; height: 550px; }

        .section-title {
            font-size: 1.3rem;
            font-weight: 700;
            margin-bottom: 1.5rem;
            color: #000;
        }

        .leaderboard {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 1rem;
            margin-bottom: 2.5rem;
        }

        .card {
            background: white;
            border: 1px solid #ddd;
            border-radius: 6px;
            padding: 1rem;
            transition: all 0.2s ease;
            box-shadow: 0 1px 3px rgba(0,0,0,0.08);
        }

        .card.clickable { cursor: pointer; }

        .card.clickable:hover {
            border-color: #0066cc;
            box-shadow: 0 4px 12px rgba(0,102,204,0.15);
            transform: translateY(-2px);
        }

        .card-title {
            font-weight: 700;
            font-size: 0.95rem;
            margin-bottom: 0.7rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .card-title .dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            flex: none;
        }

        .card-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.5rem;
            font-size: 0.8rem;
        }

        .card-label { color: #666; }

        .card-value {
            font-weight: 600;
            color: #000;
            text-align: right;
        }

        .holdings-line {
            font-size: 0.75rem;
            color: #666;
            line-height: 1.5;
            margin-top: 0.4rem;
        }

        .holdings-line b { color: #333; }

        .return-section {
            margin-top: 0.7rem;
            padding-top: 0.7rem;
            border-top: 1px solid #eee;
        }

        .return-value {
            font-size: 1.3rem;
            font-weight: 700;
            text-align: right;
        }

        .positive { color: #28a745; }
        .negative { color: #d73a49; }

        .filter-bar {
            display: flex;
            flex-wrap: wrap;
            gap: 0.6rem;
            align-items: center;
            margin-bottom: 1.5rem;
        }

        .chip {
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.4rem 0.9rem;
            background: white;
            border: 1px solid #ddd;
            border-radius: 999px;
            font-size: 0.85rem;
            font-weight: 600;
            color: #333;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .chip:hover { border-color: #0066cc; }

        .chip.active {
            border-color: #0066cc;
            background: #eaf3fc;
            color: #004a99;
        }

        .chip .dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            flex: none;
        }

        .filter-sep {
            width: 1px;
            height: 1.6rem;
            background: #ddd;
            margin: 0 0.3rem;
        }

        .table-card {
            background: white;
            border-radius: 8px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            margin-bottom: 1rem;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.88rem;
        }

        th {
            background: #fafafa;
            padding: 0.75rem 1rem;
            text-align: left;
            font-weight: 600;
            color: #666;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            border-bottom: 1px solid #ddd;
            white-space: nowrap;
        }

        td {
            padding: 0.7rem 1rem;
            border-bottom: 1px solid #f0f0f0;
            vertical-align: top;
        }

        tbody tr:not(.day-row):hover { background: #f9fbfd; }

        .day-row td {
            background: #f5f7fa;
            font-weight: 700;
            font-size: 0.8rem;
            color: #555;
            padding: 0.45rem 1rem;
            border-bottom: 1px solid #e5e5e5;
        }

        .num {
            text-align: right;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }

        th.num { text-align: right; }

        .time-cell { color: #666; white-space: nowrap; font-variant-numeric: tabular-nums; }

        .agent-cell {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-weight: 600;
            white-space: nowrap;
        }

        .agent-cell .dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            flex: none;
        }

        .symbol-cell { font-weight: 700; white-space: nowrap; }

        .badge {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
            padding: 0.2rem 0.6rem;
            border-radius: 4px;
            font-size: 0.78rem;
            font-weight: 700;
            white-space: nowrap;
        }

        .badge.buy { background: #e6f4ea; color: #1a7f37; }
        .badge.sell { background: #fceef0; color: #c92a3f; }

        .reasoning-cell {
            max-width: 420px;
            min-width: 240px;
            color: #555;
            line-height: 1.45;
            cursor: pointer;
        }

        .reasoning-cell .clamp {
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .reasoning-cell.expanded .clamp {
            -webkit-line-clamp: unset;
            overflow: visible;
        }

        .no-trades {
            text-align: center;
            color: #999;
            padding: 3rem;
        }

        footer {
            text-align: center;
            color: #999;
            font-size: 0.85rem;
            padding: 0 2rem 2.5rem;
            line-height: 1.7;
        }

        /* HTML legend replaces the Plotly legend on mobile — flex wrapping
           never clips items, unlike Plotly's horizontal legend. */
        .chart-legend { display: none; }

        @media (max-width: 768px) {
            header { padding: 1rem; }
            .container { margin: 1rem auto; padding: 0 0.75rem; }
            .title { font-size: 1.5rem; }
            .subtitle { font-size: 0.85rem; }
            .title-section { margin-bottom: 1.25rem; }

            .chart-wrapper {
                padding: 0.75rem 0.25rem 0.75rem 0;
                margin-bottom: 1.5rem;
            }

            #portfolio-chart { height: 360px; }

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

            .chart-legend {
                display: flex;
                flex-wrap: wrap;
                justify-content: center;
                gap: 0.35rem 1rem;
                padding: 0.6rem 0.5rem 0;
                font-size: 0.85rem;
                font-weight: 600;
                color: #333;
            }

            .chart-legend .item {
                display: inline-flex;
                align-items: center;
                gap: 0.4rem;
            }

            .chart-legend .swatch {
                width: 16px;
                height: 3px;
                border-radius: 2px;
                flex: none;
            }

            table { font-size: 0.82rem; }
            th, td { padding: 0.5rem 0.6rem; }
            .day-row td { padding: 0.4rem 0.6rem; }
            .reasoning-cell { min-width: 170px; max-width: 260px; }

            /* Qty (5) and Price (6) add little on a phone — Amount tells the
               story. Day-separator rows are a single colspan cell, unaffected. */
            th:nth-child(5), td:nth-child(5),
            th:nth-child(6), td:nth-child(6) {
                display: none;
            }
        }
        /* ---- 2026-09 redesign: modeled on the reference arena page (white, thin, chart + benchmark panel + cards) ---- */
        body { background: #fff; color: #111827; font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
        header.nav { background: #fff; border-bottom: 1px solid #e5e7eb; padding: 0 2rem; height: 64px;
                     display: flex; align-items: center; justify-content: space-between; }
        header.nav .logo { font-size: 1.05rem; font-weight: 600; gap: 0.6rem; }
        header.nav .logo svg { width: 18px; height: 18px; }
        header.nav .links { display: flex; gap: 2rem; align-items: center; }
        header.nav .links a { color: #6b7280; font-size: 0.9rem; font-weight: 500; text-decoration: none; }
        header.nav .links a:hover { color: #111827; }
        .wrap { max-width: 1500px; margin: 0 auto; padding: 2.5rem 1.5rem 3rem; }
        .exp-title { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.01em; color: #111827; }
        .exp-sub { color: #6b7280; font-size: 0.95rem; margin: 0.6rem 0 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid #f0f0f0; }
        .main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 2rem; align-items: start; }
        .chart-col { min-width: 0; }
        .plot-box { position: relative; }
        #portfolio-chart { width: 100%; height: 540px; }
        .icon-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
        .agent-icon { position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; background: #fff;
                      border: 2px solid #999; color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center;
                      justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.25); transition: top 0.25s ease; }
        .agent-icon.sm { font-size: 7.5px; }
        .unit-toggle { position: absolute; left: 0; top: 0; z-index: 3; display: flex; background: #fff; border: 1px solid #e5e7eb;
                       border-radius: 8px; padding: 3px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
        .unit-toggle button { border: 0; background: transparent; padding: 6px 14px; border-radius: 6px; font-size: 0.9rem;
                              font-weight: 600; color: #6b7280; cursor: pointer; }
        .unit-toggle[hidden] { display: none; }
        .unit-toggle button.on { background: #111827; color: #fff; }
        .replay { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 0.9rem; align-items: center; margin: 0.6rem 0 0; padding: 0 4rem 0 3rem; }
        .replay button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #2f2f33; color: #fff; cursor: pointer; font-size: 0.8rem; }
        .replay input[type=range] { width: 100%; accent-color: #2f2f33; }
        .replay .state { font-size: 0.85rem; color: #4b5563; min-width: 5.5rem; }
        .replay-dates { display: flex; justify-content: space-between; padding: 0 4rem 0 3rem; margin-left: 3rem; color: #6b7280; font-size: 0.72rem; }
        .agent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.9rem; margin-top: 1.6rem; }
        .agent-card { border: 2px solid #999; border-radius: 10px; padding: 0.6rem 0.8rem; cursor: pointer; background: #fff; }
        .agent-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
        .agent-card .n { font-size: 0.72rem; color: #4b5563; }
        .agent-card .r { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0.15rem; }
        .agent-card .v { font-size: 1.05rem; font-weight: 700; }
        .agent-card .p { font-size: 0.78rem; font-weight: 700; }
        .side-panel h3 { font-size: 1rem; font-weight: 600; padding-bottom: 0.7rem; border-bottom: 1px solid #f0f0f0; margin-bottom: 1.1rem; }
        .bench-head { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; }
        .bench-head .tag { background: #f3f4f6; border-radius: 6px; padding: 2px 8px; font-size: 0.78rem; font-weight: 600; }
        .bench-desc { color: #6b7280; font-size: 0.82rem; margin: 0.4rem 0 1.1rem; }
        .panel-box { border: 1px solid #eef0f2; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); padding: 1rem 1.2rem; margin-bottom: 1.1rem; }
        .kv { display: flex; justify-content: space-between; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px solid #f3f4f6; font-size: 0.85rem; color: #6b7280; }
        .kv:last-child { border-bottom: 0; }
        .kv b { color: #111827; font-size: 0.95rem; }
        .kv.big b { font-size: 1.35rem; }
        .about p { color: #6b7280; font-size: 0.82rem; line-height: 1.55; margin-top: 0.6rem; }
        .about h4 { font-size: 1rem; font-weight: 600; }
        .site-foot { border-top: 1px solid #e5e7eb; margin-top: 3rem; padding: 1.4rem 0; color: #6b7280; font-size: 0.9rem; }
        .positive { color: #16a34a; } .negative { color: #dc2626; }

        /* fit chart + slider in one screen */
        header.nav { height: 52px; }
        .wrap { padding-top: 0.9rem; }
        .exp-title { font-size: 1.35rem; }
        .exp-sub { margin: 0.2rem 0 0.7rem; padding-bottom: 0.7rem; font-size: 0.85rem; }
        .title-section { margin-bottom: 0.7rem !important; padding-bottom: 0.7rem !important; }
        #portfolio-chart { height: clamp(340px, calc(100vh - 300px), 700px); }
        .replay { margin-top: 0.2rem; }
        .unit-toggle { top: 0; }
        @media (max-width: 1000px) { .main-grid { grid-template-columns: minmax(0, 1fr); } }
        @media (max-width: 768px) {
            header.nav { padding: 0 1rem; height: 56px; } header.nav .links { gap: 1rem; } header.nav .links a, header.nav .logo { white-space: nowrap; }
            header.nav .app-version, header.nav .mode-badge { display: none; }
            .wrap { padding: 1.4rem 0.9rem 2rem; } .exp-title { font-size: 1.35rem; }
            #portfolio-chart { height: 380px; }
            .replay { padding: 0 2.6rem 0 0; } .replay-dates { padding: 0 2.6rem 0 0; margin-left: 0; }
            .agent-icon { width: 22px; height: 22px; margin: -11px 0 0 -11px; font-size: 8px; border-width: 1.5px; }
        }
        /* were style="" attributes (CSP style-src without 'unsafe-inline', 2026-10-11) */
        .wrap-top { padding-bottom: 0; }
        .title-top { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid #f0f0f0; }
        .exp-sub-flat { border: 0; padding: 0; margin: 0.6rem 0 0; }
        #rangeToggle { left: 112px; }
        .clamp .none { color: #bbb; }
