/* Results Area */
.results-area {
    flex: 1;
    overflow: visible;
    /* Let parent scroll */
    position: relative;
    background: #ffffff;
    display: none;
    flex-direction: column;
    z-index: 10;
    min-height: 0;
}

.results-area.active {
    display: block;
    /* [Fix] Natural flow */
    width: 100%;
}

/* Remove old hidden logic if redundant, or keep for safety */
.results-area.hidden,
.logic-canvas.hidden,
.state-clarify.hidden {
    display: none !important;
}

.state-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    opacity: 0.6;
}

.state-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Results Grid & Cards */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: var(--results-pad);
    background: #fdfdfd;
}

.result-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
}

/* In-feed ad card */
.ad-card {
    grid-column: 1 / -1;
    background: #fafafa;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 90px;
    overflow: hidden;
}

.ad-card .ad-slot {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Lazy rendering sentinel — invisible trigger for IntersectionObserver */
.lazy-sentinel {
    grid-column: 1 / -1;
    height: 1px;
    visibility: hidden;
    pointer-events: none;
}

.side-infeed-ad {
    margin-top: 12px;
    padding: 8px;
    border-radius: 10px;
    overflow: hidden;
}

.side-infeed-ad .ad-slot {
    width: 100%;
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-light);
}

.result-card h4 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 700;
    /* Typography Safety */
    line-height: 1.4;
    /* [Fix] Better spacing */
    word-break: keep-all;
    overflow-wrap: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-card .meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0;
    /* [Fix] Remove negative margin preventing overlap */
    display: flex;
    align-items: center;
    gap: 6px;
}

.result-card .meta .ticker-label {
    background: var(--studio-canvas);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-secondary);
}

.result-card .stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 12px 0;
}

.result-card .stat-box {
    background: #f9fafb;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-card .stat-label {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
}

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

.result-card .stat-sub {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.3;
}

.result-card .stat-percentile {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    margin-top: 2px;
}
.result-card .stat-percentile.pct-low-good  { color: #2563eb; }   /* 저PER/PBR = 저평가 */
.result-card .stat-percentile.pct-high-bad  { color: #ea580c; }   /* 고PER/PBR = 고평가 */
.result-card .stat-percentile.pct-high-good { color: #16a34a; }   /* 고ROE/배당 = 좋음 */
.result-card .stat-percentile.pct-low-bad   { color: #dc2626; }   /* 저ROE = 나쁨 */

.result-card .market-cap-wide {
    grid-column: span 2;
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-card .market-cap-wide .label {
    color: var(--muted);
    font-size: 0.8rem;
}

.result-card .market-cap-wide .value {
    font-weight: 700;
    color: var(--accent-primary);
}

.result-card .card-filter-context {
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
    margin-top: 2px;
}

.result-card .card-filter-context-head {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 10px;
}

.result-card .card-filter-chip-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.result-card .card-filter-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #eef2f7;
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1.2;
}

.result-card .card-filter-chip-label {
    color: var(--muted);
    font-weight: 600;
    margin-right: 8px;
}

.result-card .card-filter-chip-value {
    color: var(--text-primary);
    font-weight: 700;
    text-align: right;
}

.result-card .card-filter-chip.is-na {
    background: #fcfcfd;
    border-color: #edf0f2;
}

.result-card .card-filter-chip.is-na .card-filter-chip-value {
    color: #94a3b8;
}

.result-card .card-filter-more {
    margin-top: 4px;
    font-size: 0.74rem;
    color: #6b7280;
    text-align: right;
}

.result-card .actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
}

.result-card .btn-link {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.result-card .btn-dart {
    background: #eff6ff;
    color: #1e40af;
}

.result-card .btn-kind {
    background: #f0fdf4;
    color: #166534;
}

.result-card .btn-link:hover {
    filter: brightness(0.95);
}

/* ── Stock Info Dropdown ─────────────────────────────────── */
.stock-info-dropdown {
    position: relative;
    flex: 1;
}

.result-card .btn-info-trigger {
    width: 100%;
    background: #f5f3ff;
    color: #5b21b6;
    border: none;
}

.stock-info-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 20;
    overflow: hidden;
}

.stock-info-dropdown.open .stock-info-menu {
    display: block;
}

.stock-info-item {
    display: block;
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
}

.stock-info-item:hover {
    background: var(--accent-light, #eff6ff);
    color: var(--accent-primary, #1e40af);
}

.stock-info-item + .stock-info-item {
    border-top: 1px solid #f3f4f6;
}

.result-card .na-text {
    color: #9ca3af;
    font-weight: 400;
    font-size: 0.9em;
    cursor: help;
}

.ticker {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    margin-left: 6px;
}

/* =========================================
   RIGHT PANE: ASSET LIBRARY
   ========================================= */
.pane-right {
    width: var(--right-width);
    border-left: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
}

.pane-nav {
    display: flex;
    border-bottom: 1px solid var(--border-light);
}

.nav-tab {
    flex: 1;
    text-align: center;
    padding: 16px 0;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

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

.store-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.store-item,
.asset-item {
    padding: 16px 20px;
    border-bottom: none;
    cursor: default;
    transition: all 0.2s;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
    position: relative;
}

.store-list .asset-item::after {
    content: '';
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 0;
    border-bottom: 1px solid rgba(221, 225, 217, 0.55);
    pointer-events: none;
}

.store-list .asset-item:last-child::after {
    display: none;
}

.asset-item:hover {
    background: rgba(30, 120, 255, 0.04);
}

.asset-info {
    flex: 1;
    min-width: 0;
}

.asset-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    white-space: normal;
}

.asset-meta {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asset-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    width: 92px;
    min-width: 92px;
    flex-shrink: 0;
    align-self: center;
    margin-top: 0;
    padding-left: 0;
    border: none;
    border-radius: 0;
    overflow: visible;
    background: transparent;
}

.asset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 30px;
    padding: 0 6px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: #fff;
    border: 1px solid #ccd5cb;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease, background 0.2s ease, transform 0.12s ease;
    text-decoration: none;
    white-space: nowrap;
}

.asset-btn:hover,
.asset-btn:focus-visible {
    color: var(--accent-strong);
    background: rgba(30, 120, 255, 0.06);
}

.asset-btn:active {
    background: rgba(30, 120, 255, 0.12);
    transform: translateY(1px);
}

.asset-btn:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(30, 120, 255, 0.22);
}

.asset-btn.ghost {
    color: var(--text-secondary);
    background: transparent;
}

.asset-btn.ghost:hover,
.asset-btn.ghost:focus-visible {
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.08);
}

.catalog-entry-btn {
    width: auto;
    min-width: 86px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border-color: var(--border-light);
    background: #fff;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
}

.catalog-entry-btn:hover,
.catalog-entry-btn:focus-visible {
    color: var(--accent-primary);
    border-color: rgba(30, 120, 255, 0.36);
    background: var(--accent-soft);
}

.catalog-entry-btn:active {
    transform: translateY(1px);
}

.catalog-pills-row {
    padding: 12px 16px;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    border-bottom: 1px solid var(--border-light);
    background: #FAFAFA;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.catalog-pills-row::-webkit-scrollbar {
    display: none;
}

.catalog-pill {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.catalog-pill.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

.mini-btn {
    border: 1px solid var(--border-light);
    background: #fff;
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.mini-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mini-btn.active {
    background: var(--accent-soft);
    border-color: var(--accent-light);
    color: var(--accent-strong);
}

.empty-msg {
    padding: 40px 24px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Popular Rank */
.asset-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.rank-high {
    background: var(--accent-strong);
    color: #fff;
}

.rank-normal {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
