:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;
    --secondary-hover: #059669;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --input-bg: #ffffff;
    --gauge-empty: #e2e8f0;
}

:root[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary-color: #10b981;
    --secondary-hover: #34d399;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --input-bg: #0f172a;
    --gauge-empty: #334155;
}

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

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: var(--primary-color);
}

/* Common Layout */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Header & Brand Layout */
.top-header {
    background-color: var(--card-bg);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
}

@media (min-width: 769px) {
    .top-header {
        position: sticky;
        top: 0;
    }
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-main);
    transition: opacity 0.2s;
}

.brand-link:hover {
    opacity: 0.8;
}

.brand-image {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    margin-right: 0.5rem;
    box-shadow: var(--shadow-sm);
    object-fit: cover;
}

.brand-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }
    .page-title {
        font-size: 1.1rem;
    }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    color: var(--text-main);
}

.card h2 .icon {
    margin-right: 0.5rem;
}

/* AdSense Container */
.ad-container {
    display: block;
    width: 100%;
    min-width: 280px;
    margin: 0 0 2rem 0;
    text-align: center;
    border-radius: var(--radius-md);
    overflow: hidden;
    min-height: 100px;
    background-color: var(--card-bg); /* Fallback background for empty space */
}

/* Inputs */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.input-group input:not([type="radio"]):not([type="checkbox"]),
.input-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--input-bg);
    color: var(--text-main);
}

.input-group input:not([type="radio"]):not([type="checkbox"]):focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.input-group input[type="radio"],
.input-group input[type="checkbox"] {
    width: auto;
    accent-color: var(--primary-color);
    transform: scale(1.1);
    cursor: pointer;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.divider {
    text-align: center;
    margin: 2rem 0 1rem;
    position: relative;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.divider::before, .divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background-color: var(--border-color);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
}

.primary-btn:active {
    transform: scale(0.98);
}

.secondary-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.secondary-btn:hover {
    background-color: var(--secondary-hover);
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    color: var(--text-main);
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: var(--border-color);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--border-color);
    font-weight: 600;
}

tr.active-row {
    font-weight: 700;
    color: white;
}

/* Footer Sitemap */
.footer-sitemap {
    background-color: #f8fafc;
    border-top: 1px solid var(--border-color);
    padding: 3rem 2rem;
    margin-top: 4rem;
}

.sitemap-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

@media (max-width: 768px) {
    .sitemap-container {
        grid-template-columns: 1fr; /* 모바일에서는 1단으로 통일하여 빈칸 제거 */
        gap: 0; /* sitemap-col 사이의 간격을 없앰 */
    }
}

.sitemap-category {
    margin-bottom: 1rem;
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.sitemap-category summary {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    padding: 1rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background-color 0.2s;
}

.sitemap-category summary::after {
    content: "▼";
    font-size: 0.8rem;
    transition: transform 0.3s;
    color: var(--text-muted);
}

.sitemap-category[open] summary {
    border-bottom: 1px solid var(--border-color);
}

.sitemap-category[open] summary::after {
    transform: rotate(180deg);
}

.sitemap-col ul {
    list-style: none;
    padding: 1rem;
    margin: 0;
    background-color: var(--bg-color);
}

.sitemap-col ul li {
    margin-bottom: 0.5rem;
}

.sitemap-col ul li a {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.2s;
}

.sitemap-col ul li a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Legal Footer */
.site-footer {
    background-color: #ffffff;
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer-content p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

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

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: #ef4444;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-weight: 500;
    animation: slideInUp 0.3s ease forwards, fadeOut 0.3s ease 2.7s forwards;
}

.toast.success {
    background: var(--secondary-color);
}

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

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Print Optimization */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    .top-header, 
    .intro-section, 
    .input-card, 
    .footer-sitemap, 
    .site-footer, 
    .action-buttons, 
    #themeToggle,
    .ad-container {
        display: none !important;
    }
    
    .grid-layout {
        display: block !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
        break-inside: avoid;
        margin-bottom: 2rem !important;
        background: white !important;
        color: black !important;
    }
    
    .result-card, .schedule-card, .info-section {
        display: block !important;
        opacity: 1 !important;
    }
    
    .app-container {
        padding: 0 !important;
    }
    
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
