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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans KR', Arial, sans-serif;
    background: #0f1923;
    color: #e0e0e0;
    min-height: 100vh;
}

.wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px;
}

/* ===== Header ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #1e3a5f;
    margin-bottom: 16px;
}

header h1 { font-size: 22px; }

.status-bar {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #8899aa;
}

.dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.dot.connected { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.dot.disconnected { background: #ef4444; }

/* ===== Keyword Add Bar ===== */
.keyword-add-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.keyword-add-bar input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #1e3a5f;
    border-radius: 8px;
    background: #162333;
    color: #e0e0e0;
    font-size: 14px;
}

.keyword-add-bar input:focus {
    outline: none;
    border-color: #3b82f6;
}

.keyword-add-bar button {
    padding: 8px 18px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    font-weight: bold;
}

.keyword-add-bar button:hover { background: #2563eb; }

/* ===== Ticker List ===== */
.ticker-list {
    display: flex;
    flex-direction: column;
}

/* ===== Ticker Row (1 per keyword) ===== */
.ticker-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #1a2d42;
    overflow: hidden;
    height: 48px;
}

/* Keyword Label (fixed left) */
.ticker-label {
    flex-shrink: 0;
    width: 100px;
    background: #3b82f6;
    color: white;
    text-align: center;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    margin-right: 12px;
    position: relative;
    z-index: 1;
    cursor: default;
}

.ticker-label .kw-remove {
    position: absolute;
    top: -4px; right: -4px;
    background: #ef4444;
    color: white;
    width: 16px; height: 16px;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    border: none;
    z-index: 2;
}

.ticker-label:hover .kw-remove { display: flex; }

/* Marquee Container */
.ticker-track-wrap {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.ticker-track {
    display: flex;
    gap: 40px;
    white-space: nowrap;
    animation: scroll-left var(--duration, 30s) linear infinite;
}

.ticker-track:hover {
    animation-play-state: paused;
}

/* Individual News Card */
.ticker-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 6px 14px;
    background: #1a2d42;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 0;
}

.ticker-card:hover { background: #243549; }

.ticker-card-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
    font-size: 13px;
    color: #ccc;
}

.ticker-card-time {
    flex-shrink: 0;
    font-size: 11px;
    color: #64748b;
}

.ticker-card-source {
    flex-shrink: 0;
    padding: 2px 8px;
    background: #1e3a5f;
    border-radius: 4px;
    font-size: 11px;
    color: #60a5fa;
}

/* Empty State */
.no-news {
    color: #4a5568;
    text-align: center;
    padding: 12px;
    font-size: 13px;
    width: 100%;
}

/* Dimmed row (no news matched) */
.ticker-row.dimmed {
    opacity: 0.5;
}

/* Marquee Animation */
@keyframes scroll-left {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.open { display: flex; }

.modal-content {
    background: #1a2d42;
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid #1e3a5f;
}

.modal-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    color: #8899aa;
    font-size: 28px;
    cursor: pointer;
}

.modal-content h2 {
    font-size: 20px;
    margin-bottom: 12px;
    line-height: 1.4;
}

.modal-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 16px;
}

#modal-content {
    font-size: 15px;
    line-height: 1.6;
    color: #ccc;
    margin-bottom: 20px;
}

.modal-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #3b82f6;
    font-size: 14px;
    text-decoration: none;
    padding: 8px 16px;
    background: #1e3a5f;
    border-radius: 8px;
}

.modal-link:hover { background: #2a496e; }

.modal-companies {
    margin-top: 16px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.modal-companies .company-tag {
    background: #1a3a2e;
    color: #4ade80;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: #4a5568;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .wrapper { padding: 10px; }
    .ticker-label { width: 72px; font-size: 11px; }
    .ticker-card-title { max-width: 150px; font-size: 12px; }
}
