:root {
    --bg-dark: #05070a;
    --bg-gradient: linear-gradient(180deg, #0a0c10 0%, #05070a 100%);
    --card-bg: rgba(15, 20, 25, 0.7);
    --glass-border: rgba(0, 210, 255, 0.15);
    --primary-accent: #00d2ff;
    --secondary-accent: #0080ff;
    --text-main: #e0e0e0;
    --text-dim: #94a3b8;
    --btn-primary-bg: linear-gradient(135deg, #00d2ff 0%, #0080ff 100%);
    --btn-secondary-bg: rgba(255, 255, 255, 0.03);
    --success: #00ffcc;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

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

body {
    font-family: 'Inter', 'Outfit', -apple-system, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Main window doesn't scroll, content does */
}

/* Header */
.premium-header {
    width: 100%;
    padding: 1.5rem 1rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.verified-notice-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 210, 255, 0.08);
    border: 1px solid rgba(0, 210, 255, 0.2);
    padding: 0.35rem 1rem;
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--primary-accent);
    font-weight: 500;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.1);
    /* Removed white-space: nowrap to allow wrapping on mobile */
}

.pulse-icon {
    width: 8px;
    height: 8px;
    background: var(--primary-accent);
    border-radius: 50%;
    position: relative;
}

.pulse-icon::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-accent);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    width: 45px;
    height: 45px;
    background: transparent;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #a5a5a5);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 300;
}

/* Container */
.app-container {
    flex: 1;
    width: 100%;
    max-width: 1600px;
    height: 100%;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 auto;
}

.main-grid {
    display: grid;
    grid-template-columns: minmax(500px, 950px) 1fr;
    grid-template-rows: 1fr;
    gap: 1.5rem;
    height: 100%;
    align-items: stretch;
    min-height: 0;
}

.editor-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    /* 사이드바 내용 많을 시 스크롤 */
    padding-right: 5px;
}

.reference-section {
    flex: 1;
    /* This will force it to stretch to the bottom of the column */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Section Common */
section {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    /* overflow: hidden; */
    /* Removing this to prevent tooltip clipping */
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    color: var(--primary-accent);
}

/* Editor Section */
.tag-shortcuts {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.tag-btn:hover {
    background: var(--primary-accent);
    color: var(--bg-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 210, 255, 0.3);
}

.editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

#lyric-editor {
    flex: 1;
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.2rem;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    transition: all 0.3s ease;
}

#lyric-editor:focus {
    outline: none;
    border-color: var(--primary-accent);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.2);
}

.editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Buttons */
.primary-btn {
    background: var(--btn-primary-bg);
    color: white;
    border: none;
    padding: 0.8rem 1.8rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.3);
    filter: brightness(1.2);
}

.secondary-btn {
    background: var(--btn-secondary-bg);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Style Section */
.style-input-group {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
}

.input-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-accent);
    margin-left: 0.2rem;
}

#style-input,
#exclude-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    color: #fff;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

#style-input:focus,
#exclude-input:focus {
    outline: none;
    border-color: var(--primary-accent);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.1);
}

.copy-btn {
    height: 46px;
    padding: 0 1.5rem;
    min-width: 80px;
    justify-content: center;
}

.style-actions {
    display: none;
    /* Removed as we now use rows */
}

/* Quick Tags */
.quick-tags {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    /* Wider columns to prevent clipping */
    gap: 0.8rem;
}

.style-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.style-card:hover {
    background: rgba(0, 210, 255, 0.05);
    border-color: var(--primary-accent);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.style-card-name {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.1rem;
    color: var(--text-main);
}

.style-card-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.4;
    word-break: keep-all;
    /* Prevents awkward breaks in Korean */
}

/* Reference Section - Tabs */
.ref-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
}

.ref-tabs .tab-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    position: relative;
    transition: all 0.3s ease;
}

.ref-tabs .tab-btn.active {
    color: var(--primary-accent);
}

.ref-tabs .tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-accent);
    border-radius: 3px 3px 0 0;
}

.reference-section {
    flex: 1;
    min-height: 0;
}

.ref-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.ref-container::-webkit-scrollbar {
    width: 6px;
}

.ref-container::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer */
.premium-footer {
    width: 100%;
    text-align: center;
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.premium-footer p {
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* Toast Notification */
#toast-container {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
}

.toast {
    background: rgba(15, 12, 41, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--primary-accent);
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: slideDownIn 0.3s forwards, slideUpOut 0.3s forwards 2.7s;
}

@keyframes slideDownIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUpOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-30px);
        opacity: 0;
    }
}

/* Tooltip System */
.custom-tooltip {
    position: fixed;
    background: rgba(10, 15, 25, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--primary-accent);
    color: #fff;
    padding: 1rem;
    border-radius: 12px;
    z-index: 10000;
    pointer-events: none;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: none;
}

.tooltip-title {
    font-weight: 700;
    color: var(--primary-accent);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(0, 210, 255, 0.2);
    padding-bottom: 0.4rem;
}

.tooltip-body {
    color: var(--text-main);
}

.tooltip-tags {
    margin-top: 0.8rem;
    font-size: 0.75rem;
    color: var(--secondary-accent);
    font-family: monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem;
    border-radius: 4px;
}

/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-icon {
    font-size: 2.5rem;
    margin-bottom: 0.8rem;
}

.modal-content h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    margin-bottom: 0.8rem;
    color: #fff;
}

.modal-content p {
    font-size: 0.95rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal-actions button {
    padding: 0.8rem 1.5rem;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 1200px) {
    html {
        height: auto !important;
        overflow-y: auto !important;
    }

    body {
        height: auto !important;
        display: block !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .app-container {
        height: auto !important;
        overflow: visible !important;
    }

    .main-grid {
        grid-template-columns: 1fr;
        height: auto !important;
        overflow: visible;
    }

    .editor-section {
        height: auto !important;
        overflow: visible !important;
    }

    .sidebar-content {
        height: auto !important;
        overflow: visible !important;
    }

    .ref-container {
        max-height: none !important;
        overflow: visible !important;
    }
}

@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }

    .verified-notice-bar {
        border-radius: 12px;
        line-height: 1.4;
        text-align: left;
    }

    .input-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
    }

    .copy-btn {
        width: 100%;
        height: 40px;
    }

    .quick-tags {
        grid-template-columns: 1fr;
    }

    .tag-shortcuts {
        width: 100%;
        justify-content: center;
    }

    #lyric-editor {
        height: 350px;
    }

    .premium-footer {
        padding: 1.5rem 1rem;
    }

    .premium-footer p {
        font-size: 0.75rem;
        letter-spacing: normal;
        white-space: normal;
        transform: none;
        line-height: 1.5;
    }
}

/* 중앙 광고 영역 스타일 (AdSense) */
.main-ad-area {
    margin: 1rem 0;
    padding: 0;
    display: none;
    /* 기본적으로 숨김 (설정이 있을 때만 표시) */
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    /* min-height 제거: 광고가 로드될 때만 영역을 차지하도록 함 */
    background: transparent;
    border: none;
    width: 100%;
}

@media (max-width: 768px) {
    .main-ad-area {
        margin: 0.5rem 0;
        /* 모바일에서는 높이 축소 */
    }
}