:root {
    --bg-color: #ffffff;
    --header-bg: #f8f9fa;
    --primary-color: #1a237e;
    --accent-color: #c62828;
    --text-color: #212121;
    --secondary-text: #616161;
    --border-color: #e0e0e0;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --nav-active: #1a237e;
    --up-color: #e53935;
    --down-color: #1e88e5;
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --record-color: #ff9800;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --header-bg: #1e1e1e;
    --primary-color: #5c6bc0;
    --accent-color: #ef5350;
    --text-color: #e0e0e0;
    --secondary-text: #b0b0b0;
    --border-color: #333333;
    --card-bg: #1e1e1e;
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --nav-active: #5c6bc0;
    --up-color: #f44336;
    --down-color: #42a5f5;
    --modal-overlay: rgba(0, 0, 0, 0.8);
}

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

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Market Bar */
.market-bar {
    background: linear-gradient(90deg, #1a1a1a, #2c3e50);
    color: white;
    padding: 10px 0;
    font-size: 13px;
    display: flex;
    justify-content: center;
    gap: 25px;
    overflow-x: auto;
    white-space: nowrap;
    border-bottom: 2px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.market-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 0 5px;
}

.market-label {
    font-weight: 800;
    color: #bdc3c7;
    text-transform: uppercase;
}

.market-value {
    font-weight: 700;
    letter-spacing: 0.5px;
}

.market-change {
    font-size: 11px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: rgba(255,255,255,0.1);
}

.market-change.up { color: var(--up-color); }
.market-change.down { color: var(--down-color); }

.header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.date-text {
    font-size: 14px;
    color: var(--secondary-text);
    margin-top: 4px;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-color);
    transition: all 0.2s;
}

.theme-toggle:hover {
    background-color: var(--primary-color);
    color: white;
}

.category-nav {
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-color);
    position: sticky;
    top: 85px;
    z-index: 99;
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    gap: 20px;
    padding: 0 20px;
    overflow-x: auto;
    scrollbar-width: none;
}

.nav-container::-webkit-scrollbar {
    display: none;
}

.nav-item {
    background: none;
    border: none;
    padding: 15px 5px;
    font-size: 15px;
    font-weight: 600;
    color: var(--secondary-text);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--nav-active);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--nav-active);
}

.main-content {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

/* News Cards */
.hero-section {
    margin-bottom: 40px;
}

.hero-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.hero-content {
    padding: 30px;
}

.hero-category {
    display: inline-block;
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.hero-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 15px;
    line-height: 1.3;
}

.hero-summary {
    color: var(--secondary-text);
    margin-bottom: 20px;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
}

.news-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.category-tag {
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}

.news-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
}

.news-summary-list {
    list-style: none;
    margin-bottom: 15px;
}

.news-summary-list li {
    font-size: 14px;
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
    line-height: 1.5;
}

.news-summary-list li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.news-summary-list li button {
    background: none;
    border: none;
    text-align: left;
    color: var(--text-color);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    transition: all 0.2s;
    width: 100%;
    padding: 4px 8px;
    border-radius: 4px;
}

.news-summary-list li button:hover {
    color: var(--primary-color);
    background-color: var(--header-bg);
    text-decoration: underline;
}

.insight-box {
    margin-top: auto;
    background-color: var(--header-bg);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.insight-box p {
    font-size: 13px;
    font-style: italic;
    color: var(--text-color);
}

.insight-label {
    font-weight: 800;
    font-size: 11px;
    color: var(--primary-color);
    display: block;
    margin-bottom: 4px;
    text-transform: uppercase;
}

/* Apartment Section */
.apartment-section {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 800;
}

.badge {
    background-color: var(--accent-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.apartment-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.apartment-item {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr 0.8fr;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.apartment-item:last-child {
    border-bottom: none;
}

.apartment-item:hover {
    background-color: var(--header-bg);
}

.apt-main-info {
    display: flex;
    flex-direction: column;
}

.apt-name {
    font-weight: 700;
    font-size: 15px;
}

.apt-area {
    color: var(--secondary-text);
    font-size: 13px;
}

.apt-price-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.current-price, .prev-price {
    display: flex;
    gap: 8px;
    font-size: 13px;
}

.current-price .label { color: var(--accent-color); font-weight: 800; }
.current-price .value { font-weight: 800; }
.prev-price .label { color: var(--secondary-text); }
.prev-price .value { color: var(--secondary-text); text-decoration: line-through; }

.apt-change-info {
    display: flex;
    flex-direction: column;
    text-align: right;
    padding-right: 20px;
}

.price-change {
    font-weight: 800;
    color: var(--up-color);
    font-size: 14px;
}

.pyeong-price {
    font-size: 12px;
    color: var(--primary-color);
    font-weight: 600;
}

.apt-date {
    font-size: 12px;
    color: var(--secondary-text);
    text-align: right;
}

.source-text {
    font-size: 11px;
    color: var(--secondary-text);
    margin-top: 15px;
    text-align: right;
    font-style: italic;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 10% auto;
    padding: 40px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
    animation: modalFadeIn 0.3s ease;
}

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

.close-modal {
    color: var(--secondary-text);
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover {
    color: var(--text-color);
}

.modal-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--primary-color);
    line-height: 1.4;
}

.modal-detail-text {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-color);
    white-space: pre-line;
}

/* Footer */
.footer {
    background-color: var(--header-bg);
    border-top: 1px solid var(--border-color);
    padding: 60px 0 30px;
    margin-top: 80px;
}

.footer-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.newsletter-section h3 {
    font-size: 20px;
    margin-bottom: 10px;
}

.newsletter-section p {
    color: var(--secondary-text);
    margin-bottom: 25px;
}

.newsletter-form {
    display: flex;
    gap: 10px;
    max-width: 500px;
    margin: 0 auto 40px;
}

.newsletter-form input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.subscribe-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.subscribe-btn:hover {
    background-color: #0d1642;
}

.footer-bottom {
    font-size: 13px;
    color: var(--secondary-text);
    border-top: 1px solid var(--border-color);
    padding-top: 30px;
}

@media (max-width: 850px) {
    .apartment-item {
        grid-template-columns: 1.2fr 1fr;
        gap: 15px;
    }
    .apt-change-info {
        text-align: left;
        padding-right: 0;
    }
    .apt-date {
        grid-column: span 2;
        text-align: left;
        border-top: 1px dashed var(--border-color);
        padding-top: 5px;
    }
}

@media (max-width: 600px) {
    .newsletter-form {
        flex-direction: column;
    }
    .hero-title {
        font-size: 22px;
    }
    .market-bar {
        justify-content: flex-start;
        padding-left: 20px;
    }
}
