:root {
            --bg: #10100f;
            --panel: rgba(27, 25, 22, 0.9);
            --panel-soft: rgba(38, 34, 29, 0.74);
            --line: rgba(214, 177, 103, 0.24);
            --gold: #d6b167;
            --mint: #4f9d75;
            --rose: #b9493f;
            --sky: #4c7ea8;
            --earth: #a8875d;
            --ink: #f6efe0;
        }

        * { box-sizing: border-box; }
        body {
            min-height: 100vh;
            margin: 0;
            font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
            background:
                linear-gradient(120deg, rgba(79, 157, 117, 0.16), transparent 24rem),
                linear-gradient(260deg, rgba(185, 73, 63, 0.13), transparent 22rem),
                linear-gradient(180deg, #151412 0%, #211c18 48%, #10100f 100%);
            color: var(--ink);
        }

        .serif { font-family: "Playfair Display", Georgia, serif; }
        .app-shell { max-width: 1440px; margin: 0 auto; padding: 24px; }
        .app-hero {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(220px, 360px) minmax(180px, auto);
            gap: 20px;
            align-items: end;
        }
        .hero-art {
            width: 100%;
            height: 210px;
            border: 1px solid rgba(214, 177, 103, 0.22);
            border-radius: 8px;
            object-fit: cover;
            object-position: center;
            box-shadow: 0 18px 44px rgba(6, 4, 2, 0.28);
        }
        .empty-visual-layout {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(210px, 320px);
            gap: 28px;
            align-items: center;
        }
        .empty-art {
            width: 100%;
            aspect-ratio: 4 / 3;
            border: 1px solid rgba(214, 177, 103, 0.2);
            border-radius: 8px;
            object-fit: cover;
            box-shadow: 0 18px 42px rgba(6, 4, 2, 0.24);
        }
        .section-title-with-art {
            display: flex;
            align-items: center;
            gap: 14px;
            min-width: 0;
        }
        .section-title-with-art img {
            width: 92px;
            height: 64px;
            flex: 0 0 auto;
            border: 1px solid rgba(214, 177, 103, 0.2);
            border-radius: 8px;
            object-fit: cover;
            box-shadow: 0 10px 24px rgba(6, 4, 2, 0.22);
        }
        .section-title-with-art.compact img {
            width: 72px;
            height: 50px;
        }
        .panel {
            background: var(--panel);
            border: 1px solid var(--line);
            border-radius: 8px;
            box-shadow: 0 18px 50px rgba(6, 4, 2, 0.32), inset 0 1px 0 rgba(246, 239, 224, 0.04);
        }
        .field {
            width: 100%;
            border: 1px solid rgba(214, 177, 103, 0.28);
            border-radius: 8px;
            background: rgba(18, 17, 15, 0.92);
            color: var(--ink);
            padding: 11px 12px;
            outline: none;
            min-width: 0;
        }
        .field:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(244, 201, 93, 0.16); }
        .label { color: #dbc799; font-size: 13px; font-weight: 600; margin-bottom: 6px; display: block; }
        .muted { color: #b8ac95; }
        .btn-primary {
            border: 0;
            border-radius: 8px;
            background: linear-gradient(135deg, #d6b167, #9f6b2d);
            color: #18130d;
            font-weight: 800;
            padding: 13px 16px;
            transition: transform 0.18s ease, box-shadow 0.18s ease;
        }
        .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(225, 154, 47, 0.24); }
        .btn-secondary {
            border: 1px solid rgba(214, 177, 103, 0.28);
            border-radius: 8px;
            color: #efe4ca;
            padding: 11px 14px;
            background: rgba(31, 28, 23, 0.86);
        }
        .switch-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 10px 0;
            border-bottom: 1px solid rgba(214, 177, 103, 0.14);
        }
        .switch-row:last-child { border-bottom: 0; }
        .metric {
            min-height: 92px;
            border: 1px solid rgba(214, 177, 103, 0.18);
            border-radius: 8px;
            background: var(--panel-soft);
            padding: 14px;
        }
        .pill {
            display: inline-flex;
            align-items: center;
            min-height: 28px;
            border-radius: 999px;
            border: 1px solid rgba(214, 177, 103, 0.28);
            padding: 4px 10px;
            color: #efe4ca;
            background: rgba(31, 28, 23, 0.74);
            font-size: 12px;
            font-weight: 700;
            white-space: nowrap;
        }
        .candidate-source-list {
            display: grid;
            grid-template-columns: 1fr;
            gap: 8px;
        }
        .candidate-chip {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            min-height: 42px;
            border: 1px solid rgba(214, 177, 103, 0.22);
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.035);
            padding: 8px 10px;
        }
        .candidate-name {
            min-width: 0;
            color: #fff7e8;
            font-size: 13px;
            font-weight: 700;
            line-height: 1.35;
            overflow-wrap: anywhere;
        }
        .source-icon {
            flex: 0 0 auto;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 28px;
            height: 28px;
            border-radius: 999px;
            font-size: 10px;
            font-weight: 800;
            text-transform: uppercase;
            color: #f7ead2;
            background: rgba(214, 177, 103, 0.12);
            border: 1px solid rgba(214, 177, 103, 0.24);
            cursor: help;
        }
        .inline-source {
            margin-left: 8px;
            vertical-align: middle;
        }
        .candidate-chip.source-ai {
            border-color: rgba(129, 140, 248, 0.5);
            background: rgba(99, 102, 241, 0.11);
        }
        .source-icon.source-ai {
            color: #c7d2fe;
            border-color: rgba(129, 140, 248, 0.5);
            background: rgba(99, 102, 241, 0.2);
        }
        .candidate-chip.source-user {
            border-color: rgba(52, 211, 153, 0.45);
            background: rgba(16, 185, 129, 0.08);
        }
        .source-icon.source-user {
            color: #a7f3d0;
            border-color: rgba(52, 211, 153, 0.45);
            background: rgba(16, 185, 129, 0.14);
        }
        .source-icon.source-system,
        .source-icon.source-sample {
            color: #fde68a;
        }
        .score-bar {
            height: 7px;
            border-radius: 999px;
            background: rgba(214, 177, 103, 0.18);
            overflow: hidden;
        }
        .score-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--gold)); }
        .tab-button {
            min-height: 42px;
            border: 1px solid rgba(214, 177, 103, 0.2);
            border-radius: 8px;
            background: rgba(31, 28, 23, 0.72);
            color: #d9c9a6;
            padding: 9px 12px;
            font-size: 13px;
            font-weight: 800;
            text-align: left;
            transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
        }
        .tab-button:hover,
        .tab-button.active {
            border-color: rgba(244, 201, 93, 0.48);
            background: linear-gradient(135deg, rgba(214, 177, 103, 0.16), rgba(79, 157, 117, 0.1));
            color: #fde68a;
        }
        .feature-view.hidden { display: none; }
        .feature-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 16px;
        }
        .feature-card {
            border: 1px solid rgba(214, 177, 103, 0.18);
            border-radius: 8px;
            background: rgba(31, 28, 23, 0.68);
            padding: 16px;
            min-height: 150px;
        }
        .card-heading {
            display: flex;
            align-items: flex-start;
            gap: 12px;
            min-width: 0;
        }
        .card-visual {
            width: 58px;
            height: 58px;
            flex: 0 0 auto;
            border: 1px solid rgba(214, 177, 103, 0.24);
            border-radius: 8px;
            object-fit: cover;
            background: rgba(18, 17, 15, 0.65);
            box-shadow: 0 10px 20px rgba(6, 4, 2, 0.18);
        }
        .selected-name-card {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            border: 1px solid rgba(214, 177, 103, 0.34);
            border-radius: 8px;
            background:
                linear-gradient(135deg, rgba(214, 177, 103, 0.13), rgba(79, 157, 117, 0.08)),
                rgba(18, 17, 15, 0.76);
            padding: 12px;
        }
        .selected-name-card.active {
            border-color: rgba(79, 157, 117, 0.58);
            box-shadow: inset 4px 0 0 rgba(79, 157, 117, 0.9);
        }
        .selected-name-input {
            width: 100%;
            border: 0;
            background: transparent;
            color: #fff7df;
            font-family: "Playfair Display", Georgia, serif;
            font-size: 24px;
            font-weight: 800;
            outline: none;
            padding: 2px 0;
        }
        .selected-name-input::placeholder { color: rgba(246, 239, 224, 0.42); }
        .choose-name-btn {
            border: 1px solid rgba(79, 157, 117, 0.5);
            border-radius: 8px;
            background: linear-gradient(135deg, rgba(79, 157, 117, 0.96), rgba(214, 177, 103, 0.86));
            color: #10100f;
            font-weight: 900;
            padding: 11px 14px;
            margin-top: 16px;
            transition: transform 0.18s ease, box-shadow 0.18s ease;
        }
        .choose-name-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 12px 24px rgba(79, 157, 117, 0.2);
        }
        .choose-name-btn.selected {
            background: linear-gradient(135deg, rgba(214, 177, 103, 0.92), rgba(168, 135, 93, 0.92));
        }
        .member-row {
            display: grid;
            grid-template-columns: 82px minmax(0, 1fr) 34px;
            grid-template-areas:
                "role name remove"
                "date year gender";
            gap: 8px;
            align-items: center;
            border: 1px solid rgba(214, 177, 103, 0.16);
            border-radius: 8px;
            background: rgba(18, 17, 15, 0.5);
            padding: 10px;
        }
        .member-row .field {
            min-height: 34px;
            padding: 7px 8px;
            font-size: 12px;
        }
        .member-role { grid-area: role; }
        .member-name { grid-area: name; }
        .member-date { grid-area: date; }
        .member-year { grid-area: year; }
        .member-gender { grid-area: gender; }
        .member-remove {
            grid-area: remove;
            justify-self: center;
            width: 30px;
            height: 30px;
            border: 1px solid rgba(185, 73, 63, 0.4);
            border-radius: 8px;
            color: #fecdd3;
            background: rgba(185, 73, 63, 0.14);
            font-size: 18px;
            line-height: 1;
        }
        .empty-inline {
            border: 1px dashed rgba(214, 177, 103, 0.28);
            border-radius: 8px;
            background: rgba(18, 17, 15, 0.46);
            color: #b8ac95;
            padding: 16px;
            font-size: 13px;
            line-height: 1.6;
        }
        .empty-inline.error {
            border-color: rgba(185, 73, 63, 0.44);
            color: #fecdd3;
            background: rgba(185, 73, 63, 0.1);
        }
        .insight-box {
            border: 1px solid rgba(214, 177, 103, 0.2);
            border-radius: 8px;
            background: rgba(214, 177, 103, 0.08);
            padding: 12px;
            color: #efe4ca;
            font-size: 13px;
            line-height: 1.7;
        }
        .score-card {
            position: relative;
            overflow: hidden;
        }
        .score-card::before {
            content: "";
            position: absolute;
            inset: 0 auto 0 0;
            width: 4px;
            background: var(--gold);
        }
        .score-card.score-good::before { background: var(--mint); }
        .score-card.score-ok::before { background: var(--gold); }
        .score-card.score-weak::before { background: var(--rose); }
        .score-badge {
            display: grid;
            place-items: center;
            min-width: 48px;
            height: 48px;
            border-radius: 8px;
            border: 1px solid rgba(214, 177, 103, 0.32);
            background: rgba(18, 17, 15, 0.72);
            color: #fde68a;
            font-size: 20px;
            font-weight: 900;
        }
        .color-row {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 8px;
        }
        .color-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            border: 1px solid rgba(214, 177, 103, 0.22);
            border-radius: 999px;
            background: rgba(18, 17, 15, 0.58);
            padding: 4px 9px;
            color: #efe4ca;
            font-size: 12px;
            font-weight: 700;
        }
        .color-dot {
            width: 13px;
            height: 13px;
            border-radius: 50%;
            border: 1px solid rgba(246, 239, 224, 0.5);
            box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
        }
        details > summary { cursor: pointer; list-style: none; }
        details > summary::-webkit-details-marker { display: none; }
        .table-wrap { overflow-x: auto; }
        table { width: 100%; border-collapse: collapse; min-width: 620px; }
        th, td { padding: 10px 12px; border-bottom: 1px solid rgba(148, 163, 184, 0.14); text-align: left; vertical-align: top; }
        th { color: #dbc799; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
        @media (max-width: 900px) {
            .app-shell { padding: 16px; }
            .app-hero {
                grid-template-columns: 1fr;
                align-items: stretch;
            }
            .hero-art {
                height: 190px;
            }
            #rate-limit-widget {
                align-items: stretch;
            }
            .empty-visual-layout {
                grid-template-columns: 1fr;
            }
            .selected-name-card { align-items: stretch; flex-direction: column; }
            .member-row {
                grid-template-columns: 74px minmax(0, 1fr) 30px;
                grid-template-areas:
                    "role name remove"
                    "date date date"
                    "year gender gender";
            }
        }
        
        /* Yin Yang Animation */
        .yin-yang {
            width: 64px;
            height: 64px;
            border-radius: 50%;
            background: linear-gradient(to left, white 50%, black 50%);
            position: relative;
            animation: spin 3s linear infinite;
            box-shadow: 0 0 25px rgba(251, 191, 36, 0.4);
        }
        .yin-yang::before, .yin-yang::after {
            content: "";
            position: absolute;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            left: 50%;
            transform: translateX(-50%);
        }
        .yin-yang::before {
            top: 0;
            background: white;
            border: 8px solid black;
            box-sizing: border-box;
        }
        .yin-yang::after {
            bottom: 0;
            background: black;
            border: 8px solid white;
            box-sizing: border-box;
        }
        @keyframes spin {
            100% { transform: rotate(360deg); }
        }
        @keyframes spin-reverse {
            100% { transform: rotate(-360deg); }
        }
        .animate-spin-slow { animation: spin 8s linear infinite; }
        .animate-spin-reverse { animation: spin-reverse 12s linear infinite; }

        /* Commercial Enhancements */
        canvas#elementsChart {
            filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
        }
        
        .harmony-card {
            transition: all 0.2s ease;
        }
        .harmony-card:hover {
            border-color: var(--gold);
            transform: translateY(-2px);
        }
        
        .badge-ai {
            background: linear-gradient(135deg, rgba(129, 140, 248, 0.2), rgba(99, 102, 241, 0.2));
            border-color: rgba(129, 140, 248, 0.4);
            color: #a5b4fc;
        }
        
        .badge-category {
            background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(214, 177, 103, 0.1));
            border-color: rgba(214, 177, 103, 0.4);
            color: var(--gold);
        }
        
        .anti-pattern-alert {
            animation: pulse-red 2s infinite;
        }
        
        @keyframes pulse-red {
            0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4); }
            70% { box-shadow: 0 0 0 6px rgba(244, 63, 94, 0); }
            100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
        }
