/* ===== CSS Variables ===== */
:root {
    --brand:        #9333EA;
    --brand-dark:   #7E22CE;
    --brand-hover:  #6B21A8;
    --brand-light:  #F3E8FF;
    --brand-light-alt: #FAF5FF;
    --brand-grad:   linear-gradient(135deg, #9333EA 0%, #EC4899 100%);
    --secondary:    #EC4899;
    --success:      #10B981;
    --warning:      #F59E0B;
    --text:         #1F2937;
    --text-muted:   #6B7280;
    --text-light:   #9CA3AF;
    --surface:      #FFFFFF;
    --bg:           #F9FAFB;
    --border:       #E5E7EB;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
    --shadow:       0 4px 12px rgba(147,51,234,0.15);
    --shadow-lg:    0 10px 24px rgba(147,51,234,0.2);
    --radius-sm:    0.5rem;
    --radius:       0.75rem;
    --radius-lg:    1rem;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===== Container ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ===== Top AdSense (full bleed) ===== */
.ad-container.top-ad {
    background: #f9fafb;
    padding: 8px 0;
    border-bottom: 1px solid var(--border, #e5e7eb);
    width: 100%;
    margin: 0;
}

/* ===== Header (full bleed) ===== */
.main-header {
    width: 100%;
    background: var(--brand-grad);
    color: #fff;
    padding: 2rem 1rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.main-header::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -5%;
    width: 340px;
    height: 340px;
    background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 60%);
    pointer-events: none;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.header-link {
    text-decoration: none;
    color: inherit;
    display: inline-block;
}

.main-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.main-header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.btn-share-header {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.35);
    color: #fff;
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background .2s;
}
.btn-share-header:hover { background: rgba(255,255,255,0.3); }

/* ===== Layout ===== */
.layout-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.main-column { flex: 1; min-width: 0; }

.app-sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.app-sidebar::-webkit-scrollbar { display: none; }

/* ===== Tab Menu ===== */
.tab-menu {
    display: flex;
    gap: 6px;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tab-menu::-webkit-scrollbar { display: none; }

.tab-btn {
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    transition: color .2s, border-color .2s;
}
.tab-btn:hover { color: var(--brand); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ===== Converter Card ===== */
.converter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

/* ===== Gender Selector ===== */
.gender-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    background: var(--bg);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.gender-btn {
    flex: 1;
    padding: 0.65rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    transition: all .2s;
    font-size: 0.95rem;
}
.gender-btn.active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: var(--shadow-sm);
}

/* ===== Input Section ===== */
.input-section { display: grid; gap: 1rem; }

.input-group { display: flex; flex-direction: column; gap: 0.4rem; }
.input-group label { font-weight: 500; color: var(--text); font-size: 0.875rem; }

.select-input,
.text-input {
    padding: 0.7rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--surface);
    transition: border-color .2s, box-shadow .2s;
}
.select-input:focus,
.text-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(147,51,234,0.1);
}

.input-hint { font-size: 0.75rem; color: var(--text-light); }

/* ===== Buttons ===== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all .2s;
}

.btn-primary {
    background: var(--brand-grad);
    color: #fff;
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border-radius: var(--radius-sm);
}
.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* ===== Result Section ===== */
.result-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
}
.result-section h3 { margin-bottom: 1rem; color: var(--text); }

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1rem;
}

.result-item {
    background: var(--brand-light-alt);
    padding: 1rem;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 2px solid transparent;
    transition: all .2s;
}
.result-item:hover {
    border-color: var(--brand);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.result-item .flag  { font-size: 1.75rem; display: block; margin-bottom: 0.4rem; }
.result-item .country { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.result-item .size { display: block; font-size: 1.4rem; font-weight: 700; color: var(--brand); }

/* ===== Popular Grid ===== */
.popular-grid {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}
.popular-grid h2 { margin-bottom: 1.25rem; color: var(--text); font-size: 1.2rem; }

#popular-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.6rem;
}

.popular-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.875rem;
    background: var(--brand-light-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    color: var(--text);
}
.popular-item:hover {
    background: var(--brand-light);
    border-color: var(--brand);
    transform: translateY(-1px);
}
.pop-q { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-a { font-weight: 700; color: var(--brand); margin-left: 0.5rem; flex-shrink: 0; }

/* ===== Info Section ===== */
.info-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}
.info-section h2 { margin-bottom: 1.25rem; color: var(--text); font-size: 1.2rem; }

.info-card {
    background: var(--bg);
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}
.info-card:last-child { margin-bottom: 0; }
.info-card h3 { margin-bottom: 0.875rem; color: var(--text); font-size: 1.05rem; }
.info-card ol, .info-card ul { margin-left: 1.5rem; }
.info-card li { margin-bottom: 0.4rem; color: var(--text-muted); }

.tip-card {
    background: linear-gradient(135deg, #FDF4FF 0%, #FCE7F3 100%);
    border-left: 4px solid var(--brand);
}

/* ===== FAQ Section ===== */
.faq-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}
.faq-section h2 { margin-bottom: 1.25rem; font-size: 1.2rem; }

.faq-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: border-color .2s;
}
.faq-item:hover { border-color: var(--brand); }
.faq-item summary { font-weight: 500; color: var(--text); cursor: pointer; user-select: none; }
.faq-item p { margin-top: 0.875rem; color: var(--text-muted); line-height: 1.7; }

/* ===== Related Grid ===== */
.related-grid {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}
.related-grid h2 { margin-bottom: 1.25rem; font-size: 1.2rem; }

.related-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.related-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--brand-light-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all .15s;
}
.related-card:hover {
    background: var(--brand-light);
    border-color: var(--brand);
    color: var(--brand);
    transform: translateY(-1px);
}
.related-card .rc-emoji { font-size: 1.25rem; flex-shrink: 0; }

/* ===== 광고 슬롯 시스템 ===== */
.ad-slot {
    display: block;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    background: var(--brand-grad);
    color: #fff;
    position: relative;
    transition: transform .15s, box-shadow .15s;
    box-shadow: var(--shadow-sm);
}
.ad-slot:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.ad-slot.banner-wide { aspect-ratio: 4/1; max-width: 800px; margin: 20px auto; }
.ad-slot.banner-square { aspect-ratio: 1/1; max-width: 320px; margin: 20px auto; }
.ad-slot .ad-inner {
    position: absolute; inset: 0;
    padding: 16px 22px;
    display: flex; flex-direction: column; justify-content: center;
    background: rgba(0,0,0,0);
}
.ad-slot.has-image .ad-inner {
    background: linear-gradient(90deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,.25) 60%, rgba(0,0,0,0) 100%);
}
.ad-slot.banner-square .ad-inner {
    padding: 18px;
    background: linear-gradient(180deg, rgba(0,0,0,.15) 0%, rgba(0,0,0,.55) 100%);
    justify-content: flex-end;
}
.ad-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.ad-slot .ad-inner { z-index: 1; }
.ad-slot .ad-label {
    position: absolute; top: 6px; right: 10px;
    font-size: 10px; font-weight: 700;
    color: rgba(255,255,255,.7);
    background: rgba(0,0,0,.25);
    padding: 2px 6px; border-radius: 4px;
    z-index: 2;
}
.ad-slot .ad-title { font-size: 18px; font-weight: 800; line-height: 1.3; letter-spacing: -.2px; }
.ad-slot.banner-square .ad-title { font-size: 17px; }
.ad-slot .ad-subtitle { font-size: 13px; opacity: 0.9; margin-top: 2px; }
.ad-slot .ad-cta {
    display: inline-block; align-self: flex-start;
    margin-top: 8px; padding: 6px 14px;
    background: #fff; color: var(--brand-dark);
    border-radius: 20px; font-size: 12px; font-weight: 700;
}
@media (max-width: 520px) {
    .ad-slot.banner-wide { aspect-ratio: 3/1; }
    .ad-slot .ad-title { font-size: 16px; }
    .ad-slot.banner-square { max-width: 300px; }
}

/* ===== AdSense containers ===== */
.ad-container { min-height: 90px; text-align: center; }
.bottom-ad { margin: 1.5rem auto; }

/* ===== Sidebar styles ===== */
.sidebar-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.sidebar-card h3 {
    font-size: 0.875rem; font-weight: 700;
    margin-bottom: 0.75rem;
    padding-left: 8px;
    border-left: 3px solid var(--brand);
    color: var(--text);
}
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a {
    display: flex; align-items: flex-start;
    text-decoration: none; color: var(--text);
    padding: 7px 8px; border-radius: 8px; transition: background .15s;
}
.sidebar-list a:hover { background: var(--brand-light); }
.link-icon { margin-right: 8px; font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.link-content { flex: 1; min-width: 0; }
.link-title {
    display: block; font-size: 13px; font-weight: 600;
    color: var(--brand); margin-bottom: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-desc { display: block; font-size: 11px; color: var(--text-light); margin-top: 1px; }

/* ===== Footer ===== */
.main-footer {
    text-align: center;
    padding: 2rem 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
}
.footer-note { margin-top: 0.5rem; font-size: 0.75rem; color: var(--text-light); }

/* ===== Toast ===== */
.toast {
    position: fixed; bottom: 2rem; left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0; pointer-events: none;
    transition: opacity .3s;
    z-index: 1000;
    white-space: nowrap;
}
.toast.show { opacity: 1; pointer-events: auto; }

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .app-sidebar { width: 240px; }
}

@media (max-width: 768px) {
    .layout-container { flex-direction: column; padding: 0 0.875rem; }
    .app-sidebar { width: 100%; position: static; max-height: none; }
    .main-header h1 { font-size: 1.5rem; }
    .main-header .subtitle { font-size: 1rem; }
    .result-grid { grid-template-columns: repeat(3, 1fr); }
    .converter-card { padding: 1.25rem; }
    .info-section, .faq-section, .popular-grid, .related-grid { padding: 1.25rem; }
    #popular-list { grid-template-columns: 1fr 1fr; }
    .related-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
    .container { padding: 0 0.75rem; }
    .layout-container { padding: 0 0.75rem; }
    .result-grid { grid-template-columns: repeat(2, 1fr); }
    .gender-selector { flex-direction: column; }
    #popular-list { grid-template-columns: 1fr; }
    .related-cards { grid-template-columns: 1fr; }
}
