:root {
    --bg-color: #0f111a;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.05);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --positive: #10b981;
    --negative: #ef4444;
    --yt-color: #ff0000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: radial-gradient(circle at 50% -20%, rgba(99, 102, 241, 0.15), transparent 50%),
                      radial-gradient(circle at -20% 50%, rgba(236, 72, 153, 0.1), transparent 50%);
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--card-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    color: transparent;
}

.header-right {
    display: flex;
    align-items: center;
}

.market-tabs {
    display: flex;
    gap: 0.5rem;
    margin-right: 2rem;
}

.market-tab {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.market-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.market-tab.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--positive);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--positive);
}

.status-text {
    font-size: 0.85rem;
    color: var(--positive);
    font-weight: 600;
}

.hero {
    text-align: center;
    padding: 6rem 0;
}

.hero h2 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    color: transparent;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto 3rem;
    line-height: 1.6;
}

.analyze-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    padding: 1.25rem 3rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 1rem;
}

.analyze-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(99, 102, 241, 0.6);
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.analyze-btn.loading .btn-loader {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Results Section */
.results {
    animation: fadeIn 0.8s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.results-header {
    text-align: center;
    margin-bottom: 3rem;
}

.results-header h3 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.highlight {
    color: var(--secondary);
}

.results-header p {
    color: var(--text-muted);
}

.yt-analysis-card {
    background: rgba(255, 0, 0, 0.05);
    border: 1px solid rgba(255, 0, 0, 0.1);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 3rem;
    text-align: center;
}

.yt-analysis-card h4 {
    color: #ff4444;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.tags {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.tag {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.trend {
    font-size: 1.1rem;
}

.bullish { color: var(--positive); }
.bearish { color: var(--negative); }

.flash-update {
    animation: valueFlash 0.3s ease-out;
    border-radius: 4px;
    padding: 0 4px;
    display: inline-block;
}

.market-status {
    margin-top: 1rem;
    font-weight: bold;
    padding: 0.75rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.market-open {
    background: rgba(16, 185, 129, 0.1);
    color: var(--positive);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.market-closed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--negative);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--positive);
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}


/* Stock Grid */
.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.stock-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform 0.3s, box-shadow 0.3s;
    backdrop-filter: blur(10px);
    cursor: pointer; /* 클릭 가능하다는 시각적 피드백 */
}

.stock-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    border-color: rgba(99, 102, 241, 0.3);
}

.card-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 1rem;
}

.stock-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow: hidden;
}

.rank-badge {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    display: inline-block;
    white-space: nowrap;
}

.stock-info h4 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.stock-info .code {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.stock-price-container .price {
    font-size: 1.5rem;
    font-weight: 800;
    white-space: nowrap;
}

.card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric .label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.metric .value {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    letter-spacing: -0.2px;
}

.highlight-metric {
    background: rgba(255,255,255,0.05);
    padding: 0.75rem;
    border-radius: 8px;
}

.yt-color { color: #ff6b6b; }
.ai-color { color: #818cf8; }

.expected .value {
    color: var(--secondary);
    font-size: 1.25rem;
}

.trade-btn {
    width: 100%;
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 0.875rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.trade-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #fff;
}

.trade-btn.active {
    background: rgba(16, 185, 129, 0.2);
    color: var(--positive);
    border-color: var(--positive);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-color);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    width: 95%;
    max-width: 1200px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: flex-end;
    padding: 1rem 1.5rem 0;
    position: sticky;
    top: 0;
    background: var(--bg-color);
    z-index: 10;
    border-radius: 16px 16px 0 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}
.close-btn:hover {
    color: white;
}

.modal-body {
    padding: 1.5rem;
    padding-top: 0;
    overflow-y: auto;
}

/* Markdown Rendering Styles */
.markdown-body {
    color: var(--text-main);
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.markdown-body pre {
    overflow-x: auto;
    max-width: 100%;
}
.markdown-body h1 {
    font-size: 1.8rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    color: #fff;
}
.markdown-body h2 {
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #e2e8f0;
}
.markdown-body h3 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}
.markdown-body p {
    margin-bottom: 1rem;
}
.markdown-body ul {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}
.markdown-body li {
    margin-bottom: 0.5rem;
}
.markdown-body code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: #fca5a5;
}
.markdown-body blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
    margin-left: 0;
    color: #cbd5e1;
    background: rgba(99, 102, 241, 0.1);
    padding: 1rem;
    border-radius: 0 8px 8px 0;
}
.markdown-body a {
    color: var(--primary);
    text-decoration: none;
}
.markdown-body a:hover {
    text-decoration: underline;
}

/* Color classes for KR/US */
.text-red { color: #ef4444 !important; }
.text-blue { color: #3b82f6 !important; }
.text-green { color: #10b981 !important; }

.stock-price-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.price-change {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.25rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* =========================================
   📱 Mobile Responsive Design (Smartphones)
   ========================================= */
@media screen and (max-width: 768px) {
    .container {
        width: 100%;
        padding: 1rem;
    }

    header {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
        padding-bottom: 1.5rem;
    }

    .header-right {
        flex-direction: column;
        width: 100%;
        gap: 1rem;
    }

    .market-tabs {
        margin-right: 0;
        width: 100%;
        justify-content: center;
    }

    .market-tab {
        flex: 1;
        text-align: center;
        padding: 0.75rem 0.5rem;
    }

    .hero {
        padding: 3rem 0;
    }

    .hero h2 {
        font-size: 2rem;
        line-height: 1.3;
    }

    .hero p {
        font-size: 1rem;
        padding: 0 1rem;
        margin-bottom: 2rem;
    }

    .analyze-btn {
        width: 90%;
        justify-content: center;
        padding: 1rem;
    }

    .dashboard-panel {
        grid-template-columns: 1fr;
    }

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

    .card-body {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .highlight-metric {
        grid-column: span 1 !important;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .highlight-metric > div {
        text-align: left !important;
        width: 100%;
    }

    .modal-body {
        padding: 1.5rem;
        padding-top: 3rem;
    }

    .markdown-body h1 {
        font-size: 1.4rem;
    }

    .markdown-body h2 {
        font-size: 1.2rem;
    }
}
