:root {
    --primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-solid: #667eea;
    --secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #f8f9fa;
    --dark-light: #ffffff;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --bg: #f0f4f8;
    --card-bg: rgba(255, 255, 255, 0.9);
    --glass: rgba(255, 255, 255, 0.8);
    --border: rgba(0, 0, 0, 0.1);
}

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

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

/* Container - 중앙 정렬 */
.container-center {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Page Management */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Landing Page */
#landing-page {
    min-height: 100vh;
    position: relative;
    background:
        radial-gradient(1200px 600px at 15% 10%, rgba(255, 211, 105, 0.35), transparent 60%),
        radial-gradient(900px 500px at 85% 15%, rgba(59, 130, 246, 0.22), transparent 55%),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

#landing-page::before,
#landing-page::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 30%;
    filter: blur(30px);
    opacity: 0.6;
    z-index: 0;
}

#landing-page::before {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.35), rgba(251, 191, 36, 0.35));
    top: 12%;
    left: 8%;
}

#landing-page::after {
    background: linear-gradient(135deg, rgba(14, 116, 144, 0.35), rgba(59, 130, 246, 0.35));
    bottom: 12%;
    right: 10%;
}

#input-page,
#result-page {
    min-height: 100vh;
    position: relative;
    background:
        radial-gradient(1200px 600px at 10% 8%, rgba(59, 130, 246, 0.18), transparent 60%),
        radial-gradient(900px 500px at 90% 12%, rgba(16, 185, 129, 0.18), transparent 55%),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

#input-page::before,
#input-page::after,
#result-page::before,
#result-page::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 30%;
    filter: blur(30px);
    opacity: 0.55;
    z-index: 0;
}

#input-page::before,
#result-page::before {
    background: linear-gradient(135deg, rgba(14, 165, 164, 0.28), rgba(59, 130, 246, 0.28));
    top: 10%;
    left: 6%;
}

#input-page::after,
#result-page::after {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.28), rgba(34, 197, 94, 0.28));
    bottom: 12%;
    right: 8%;
}

.page-shell {
    position: relative;
    z-index: 1;
    justify-content: flex-start;
    padding-top: 3rem;
    padding-bottom: 3.5rem;
}

.page-card {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 26px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
    padding: 2.5rem 2.5rem 2.8rem;
    backdrop-filter: blur(10px);
}

.page-card .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #64748b;
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 1.2rem;
}

.page-card .back-link:hover {
    color: #0f172a;
}

.landing-hero {
    position: relative;
    z-index: 1;
    align-items: center;
    text-align: center;
    gap: 1rem;
    padding: 3rem 2.5rem;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
    max-width: 720px;
}

.landing-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f766e;
    background: rgba(20, 184, 166, 0.15);
    border: 1px solid rgba(20, 184, 166, 0.3);
    letter-spacing: 0.02em;
}

.landing-title {
    font-size: clamp(2.4rem, 4vw, 3.4rem);
    font-weight: 900;
    margin-bottom: 0.3rem;
    line-height: 1.15;
    color: #0f172a;
}

.landing-subtitle {
    font-size: 1.05rem;
    color: #475569;
    margin-bottom: 1.2rem;
}

.landing-cta {
    background: linear-gradient(120deg, #0ea5a4 0%, #22c55e 55%, #f59e0b 100%);
    box-shadow: 0 12px 30px rgba(14, 165, 164, 0.35);
    max-width: 320px;
}

.landing-cta:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 18px 40px rgba(14, 165, 164, 0.4);
}

/* Typography */
.main-title {
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 1rem;
    text-align: center;
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2rem;
    font-weight: 400;
    margin-bottom: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-align: center;
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    text-align: center;
}

/* Buttons */
.btn {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
    font-family: 'Noto Sans KR', sans-serif;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--glass);
    color: var(--text);
    border: 2px solid var(--border);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-solid);
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    margin-bottom: 2rem;
    transition: color 0.3s;
    display: block;
}

.btn-back:hover {
    color: var(--text);
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.share-buttons .btn {
    width: auto !important;
    min-width: 0;
    flex: 1;
    padding: 0.8rem 0.5rem;
    font-size: 0.9rem;
    margin: 0;
}

.btn-kakao {
    background: #FEE500;
    color: #000000;
    border: none;
    font-weight: 600;
}

.btn-kakao:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(254, 229, 0, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    color: var(--text);
    border-color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

/* Single Member Form */
.single-member-form {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.form-vertical {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text);
    font-size: 1rem;
    font-family: 'Noto Sans KR', sans-serif;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-solid);
    background: rgba(255, 255, 255, 0.08);
}

/* Added Members List */
.added-members-list {
    margin-bottom: 2rem;
}

.added-member-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.member-info-text {
    flex: 1;
}

.btn-remove-small {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    transition: transform 0.2s;
}

.btn-remove-small:hover {
    transform: scale(1.2);
}

.input-actions {
    display: flex;
    justify-content: center;
}

/* Result Page */
.result-header {
    text-align: center;
    margin-bottom: 2rem;
}

.score-card {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    text-align: center;
    width: 100%;
    pointer-events: none;
}

#group-score {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.score-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 0.2rem;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.5);
}

.score-grade {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 10px;
}

.score-comment {
    display: none;
    /* 그래프 오버레이에서는 숨김 */
}

.score-reason {
    display: none;
    /* 그래프 오버레이에서는 숨김 */
}

/* Network Section - 중앙 정렬 */
.network-section {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.network-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

#network-graph {
    width: 100%;
    height: 500px;
    /* Reduced to bring graph closer to header */
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border);
    border-radius: 15px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* SVG가 넘치는 것 방지 */
}

#network-graph svg {
    display: block;
    margin: 0 auto;
}

.network-help {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.filter-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.filter-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
    min-width: 60px;
    padding: 0 0.5rem;
}

.filter-item:hover {
    transform: translateY(-5px);
}

.filter-item span {
    font-size: 0.9rem;
    font-weight: 700;
    color: #4b5563;
    line-height: 1.2;
    margin-top: 0.5rem;
    text-align: center;
    white-space: nowrap;
}

.filter-bar {
    width: 100%;
    height: 12px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Details Section */
.details-section {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
}

.details-section h3 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

/* Side Panel (Replaces Modal) */
.side-panel {
    position: fixed;
    top: 0;
    right: -400px;
    /* Hidden via position */
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-left: 1px solid var(--border);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.side-panel.active {
    right: 0;
}

.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
}

.panel-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}

.panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    padding: 5px;
}

.panel-close:hover {
    color: var(--danger);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Graph Focus Mode */
.graph-dimmed {
    opacity: 0.1 !important;
    transition: opacity 0.3s ease;
}

.link-label-group.graph-dimmed {
    opacity: 0 !important;
    pointer-events: none;
    /* Prevent clicks on hidden labels */
}

.graph-highlight {
    opacity: 1 !important;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
    transition: opacity 0.3s ease;
}

.node circle {
    transition: all 0.3s ease;
}

.node.active circle {
    stroke: var(--primary-solid);
    stroke-width: 5px;
    fill-opacity: 1;
}

/* Modal is deprecated but kept if needed for simple alerts, 
   but we mainly use Side Panel now. 
   Removing old modal styles to avoid confusion if completely replacing.
*/

/* Loading */
.loading-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-solid);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .landing-hero {
        padding: 2.2rem 1.6rem;
        margin: 1.5rem auto;
    }

    .landing-title {
        font-size: clamp(2rem, 6vw, 2.6rem);
    }

    .landing-subtitle {
        font-size: 0.98rem;
    }

    .landing-cta {
        width: 100%;
        max-width: 320px;
    }

    .page-shell {
        padding-top: 2.2rem;
        padding-bottom: 2.6rem;
    }

    .page-card {
        padding: 1.8rem 1.4rem 2.2rem;
        border-radius: 22px;
    }

    .main-title {
        font-size: 2rem;
    }

    .main-title {
        font-size: 2rem;
    }

    /* Shift layout up when panel is open */
    .container-center.mobile-shift {
        justify-content: flex-start;
        padding-top: 2rem;
        padding-bottom: 55vh;
        /* Space for panel */
    }

    .page-title {
        font-size: 1.5rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .graph-legend {
        flex-direction: column;
        align-items: flex-start;
    }

    #network-graph {
        height: 550px;
    }

    /* Side Panel Mobile Changes: Bottom Sheet */
    .side-panel {
        top: auto;
        bottom: -60vh;
        /* Hidden */
        right: 0;
        left: 0;
        width: 100%;
        height: 50vh;
        /* Reduced from 85vh to show network */
        border-left: none;
        border-top: 1px solid var(--border);
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.15);
    }

    .side-panel.active {
        right: 0;
        /* Unset right logic if needed, but left/right 0 covers width */
        bottom: 0;
    }
}

/* Group Analysis Styles */
.group-analysis-card {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    margin-top: 3rem;
    /* 여백 추가 */
}

.keyword-badge {
    display: inline-block;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    padding: 6px 14px;
    border-radius: 20px;
    margin-right: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.95rem;
}

.analysis-section-title {
    font-size: 1.15rem;
    color: #333;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
}

.analysis-section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--primary);
    margin-right: 10px;
    border-radius: 2px;
}

.analysis-text {
    color: #4b5563;
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

.analysis-text-block {
    line-height: 1.6;
    margin-bottom: 0.5rem;
    word-break: keep-all;
    /* 한글 가독성 최적화 */
    text-align: justify;
}

.score-details-container {
    margin-top: 2.5rem;
    border-top: 1px solid #eee;
    padding-top: 2rem;
}

.score-details-box {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 15px;
}

.score-item {
    margin: 0.8rem 0;
    font-size: 1rem;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
}

.saju-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    font-size: 0.95rem;
}

.saju-table th,
.saju-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #eef2f7;
    text-align: left;
    vertical-align: middle;
}

.saju-table thead th {
    background: #f8fafc;
    color: #4b5563;
    font-weight: 700;
}

.saju-table tbody tr:last-child td {
    border-bottom: 0;
}

.saju-sub {
    color: var(--text-muted);
    margin-left: 0.25rem;
    font-size: 0.9rem;
}

.saju-pillars {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0.4rem 0.4rem;
    margin-bottom: 0.4rem;
}

.saju-pillars th,
.saju-pillars td {
    text-align: center;
    vertical-align: middle;
}

.saju-pillars thead th {
    font-size: 0.95rem;
    font-weight: 800;
    color: #b91c1c;
    padding: 0.3rem 0.4rem 0.45rem;
    line-height: 1.2;
}

.saju-row-label {
    width: 64px;
    color: #6b7280;
    font-weight: 700;
    text-align: left;
    padding-right: 0.2rem;
}

.saju-col--day {
    border: 2px solid #b91c1c;
    border-radius: 10px;
    box-sizing: border-box;
}

.saju-cell {
    height: 72px;
    border-radius: 8px;
    font-size: 2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #cbd5e1;
    background: #fff;
}

.saju-cell--day {
    border-color: #b91c1c;
}

.saju-summary {
    width: 100%;
    border-collapse: collapse;
    margin: 0.2rem 0 0.6rem;
    font-size: 0.95rem;
}

.saju-summary th,
.saju-summary td {
    padding: 0.35rem 0.2rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #eef2f7;
}

.saju-summary th {
    width: 90px;
    color: #6b7280;
    font-weight: 700;
}

.saju-summary td.saju-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 700px) {
    .saju-cell {
        height: 58px;
        font-size: 1.6rem;
    }

    .saju-row-label {
        width: 52px;
        font-size: 0.85rem;
    }

    .saju-pillars thead th {
        font-size: 0.85rem;
    }
}
