/* style.css (최종 개선 버전) */

/* ------------------------- */
/* 1. 기본 변수 및 스타일 정의 */
/* ------------------------- */
:root {
    --bg-color: #f4f7f6;
    --container-bg-color: #fff;
    --text-color: #333;
    --heading-color: #2c3e50;
    --secondary-text-color: #555;
    --border-color: #e0e6eb;
    --shadow-color: rgba(0,0,0,0.08);
    --history-hover-bg: #f8f9fa;
    --tag-bg-color: #eaf2f8;
    --tag-text-color: #3498db;
    --tag-border-color: #d4e6f1;
    --tag-hover-bg-color: #d4e6f1;
    --history-action-btn-bg: #f0f2f5;
    --history-action-btn-hover-bg: #e4e6e9;
    --ad-bg-color: #eef2f6; /* 광고 배경색 */
    --ad-border-color: #dee2e6; /* 광고 테두리색 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* ------------------- */
/* 2. 다크 모드 스타일 */
/* ------------------- */
body.dark-mode {
    --bg-color: #1a202c;
    --container-bg-color: #2d3748;
    --text-color: #e2e8f0;
    --heading-color: #a0aec0;
    --secondary-text-color: #a0aec0;
    --border-color: #4a5568;
    --shadow-color: rgba(0,0,0,0.4);
    --history-hover-bg: #4a5568;
    --tag-bg-color: #3498db;
    --tag-text-color: #fff;
    --tag-border-color: #3498db;
    --tag-hover-bg-color: #2980b9;
    --history-action-btn-bg: #4a5568;
    --history-action-btn-hover-bg: #5a6678;
    --ad-bg-color: #374151; /* 다크모드 광고 배경색 */
    --ad-border-color: #4a5568; /* 다크모드 광고 테두리색 */
}

/* ----------------- */
/* 3. 레이아웃 및 공용 */
/* ----------------- */
.main-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}
.content-area {
    flex: 1;
    min-width: 0;
}
.container {
    background: var(--container-bg-color);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px var(--shadow-color);
    margin-bottom: 20px;
}
button {
    padding: 12px 20px;
    cursor: pointer;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
button:hover {
    background-color: #2980b9;
}
button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}
.icon-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--secondary-text-color);
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}
.icon-btn:hover {
    background-color: var(--history-hover-bg);
}
.icon-btn svg {
    stroke: currentColor;
}
.copy-btn {
    background-color: #7f8c8d;
    color: white;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
}
.copy-btn:hover {
    background-color: #95a5a6;
}
.copy-btn.copied {
    background-color: #2ecc71;
}
.btn-loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    display: none;
    animation: spin 0.8s linear infinite;
}
#createBtn.loading .btn-text { display: none; }
#createBtn.loading .btn-loader { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------- */
/* 4. 헤더 및 입력 폼 */
/* ----------------- */
/* .page-intro-header 스타일을 찾아 아래 코드로 교체하거나 속성을 추가합니다. */
.page-intro-header {
    margin-bottom: 20px;
    padding: 20px; /* 내부 여백 추가 */
    position: relative; /* 자식 요소의 위치 기준으로 설정 */
    overflow: hidden; /* 애니메이션이 영역을 벗어나지 않도록 설정 */
    background-color: var(--container-bg-color); /* 배경색 지정 */
    border-radius: 12px; /* 부드러운 모서리 */
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); /* 은은한 그림자 효과 */
}

/* 헤더 배경에 빛 효과를 위한 가상 요소 추가 */
.page-intro-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(88, 122, 245, 0.1), transparent 40%);
    animation: background-glow 15s linear infinite;
}

/* 배경 빛 효과 애니메이션 키프레임 추가 */
@keyframes background-glow {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
/* 4. 헤더 및 입력 폼 섹션에 추가 */
.input-section-card {
    background: var(--container-bg-color);
    border-radius: 12px; /* 모서리를 더 둥글게 */
    box-shadow: 0 8px 24px rgba(0,0,0,0.05); /* 부드러운 그림자 */
    transition: box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
}

.input-section-card:hover {
    box-shadow: 0 10px 28px rgba(0,0,0,0.07); /* 호버 시 그림자 강조 */
}
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
/* 4. 헤더 및 입력 폼 섹션 */

/* 기존 h1 스타일을 찾아 아래 코드로 교체합니다. */
h1 {
    font-size: 2.5em; /* 폰트 크기를 약간 키웁니다. */
    font-weight: 800; /* 폰트를 더 굵게 하여 존재감을 부각시킵니다. */
    margin: 0;
    
    /* 그라데이션 텍스트 효과 */
    background: linear-gradient(90deg, #3498db, #8e44ad, #e91e63);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;

    /* 그라데이션 애니메이션 (선택 사항) */
    animation: gradient-text-flow 10s ease infinite;
    background-size: 200% 200%;
}

/* 텍스트 그라데이션 애니메이션을 위한 키프레임 추가 */
@keyframes gradient-text-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.page-description {
    color: var(--secondary-text-color);
    margin: 5px 0 0 0;
}
.header-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}
.history-toggle-btn {
    display: none; /* 기본적으로 버튼을 숨깁니다 */
}
.generation-form {
    /* border: 1px solid var(--border-color); 이 줄을 삭제하거나 주석 처리합니다. */
    border-radius: 12px; /* 부모 요소인 input-section-card와 맞추어 줍니다. */
    overflow: hidden;
    margin-top: 0; /* 부모 요소와 간격이 필요 없으므로 0으로 설정합니다. */
}
.main-input-section {
    position: relative;
}
.main-input-section textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 20px; /* 패딩 증가 */
    padding-bottom: 70px;
    border: none; /* 모든 테두리 제거 */
    border-bottom: 1px solid var(--border-color); /* 하단 경계선 유지 */
    border-radius: 12px 12px 0 0; /* 카드의 상단 모서리에 맞춤 */
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    background-color: transparent;
    color: var(--text-color);
    transition: background-color 0.3s, box-shadow 0.3s; /* 부드러운 전환 효과 */
}

.main-input-section textarea:focus {
    outline: none;
    background-color: var(--history-hover-bg); /* 포커스 시 미세한 배경색 변경 */
    box-shadow: inset 0 -2px 0 #3498db; /* 하단에 색상 라인으로 포커스 표시 */
    border-bottom-color: transparent; /* 기존 하단 경계선 숨김 */
}
.input-footer {
    position: absolute;
    bottom: 12px;
    left: 15px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.input-counter {
    font-size: 13px;
    color: var(--secondary-text-color);
}
#createBtn {
    min-width: 120px;
    min-height: 45px;
    position: static;
}
.advanced-settings-section {
    background-color: var(--bg-color); /* 배경색을 페이지 전체 배경과 유사하게 변경 */
    padding: 20px;
    display: flex;
    gap: 20px;
    border-radius: 0 0 12px 12px; /* 카드의 하단 모서리에 맞춤 */
}
.optional-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.optional-input-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--secondary-text-color);
    font-weight: 500;
}
.optional-input-group label svg {
    color: var(--secondary-text-color);
}
.optional-input-group input {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
    background-color: var(--container-bg-color);
    color: var(--text-color);
}
.datetime-picker {
    display: flex;
    gap: 10px;
}
.datetime-picker input {
    flex: 1;
}

/* ------------------- */
/* 5. 결과 표시 영역 */
/* ------------------- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.section-header h4 {
    margin: 0;
    font-size: 1.1em;
    color: var(--heading-color);
}
.disclaimer {
    font-size: 0.85em;
    color: var(--secondary-text-color);
    text-align: center;
    margin-bottom: 15px;
}
#result {
    margin-top: 20px;
}
.result-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--container-bg-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    overflow: hidden;
}
.result-card-title-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--history-hover-bg);
    border-bottom: 1px solid var(--border-color);
}
.result-title {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: var(--heading-color);
}
.result-card-body-section {
    padding: 25px 20px;
}
.result-message {
    margin: 0;
    font-size: 1.05em;
    line-height: 1.7;
    color: var(--text-color);
}
/* ------------------- */
/* 5.5. 스켈레톤 로더 */
/* ------------------- */

@keyframes skeleton-gradient {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

#skeleton-loader .skeleton-item {
    background: linear-gradient(90deg, var(--history-hover-bg) 25%, var(--bg-color) 50%, var(--history-hover-bg) 75%);
    background-size: 200px 100%;
    animation: skeleton-gradient 1.5s infinite linear;
    border-radius: 4px;
}

#skeleton-loader .skeleton-heading {
    width: 40%;
    height: 32px;
    margin-bottom: 20px;
}

#skeleton-loader .skeleton-line {
    width: 100%;
    height: 16px;
    margin-bottom: 12px;
}

#skeleton-loader .skeleton-line-short {
    width: 60%;
    height: 16px;
    margin-bottom: 12px;
}

#skeleton-loader .skeleton-spacing-top {
    margin-top: 40px;
}

#skeleton-loader .skeleton-score-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

#skeleton-loader .skeleton-card {
    height: 120px;
}

#skeleton-loader .skeleton-draft {
    height: 60px;
}

/* --- 점수 카드 --- */
#score-details-container { margin-top: 40px; display: none; }
.score-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 10px;
}
.score-card {
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--container-bg-color);
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.score-card-header {
    display: flex;
    align-items: center;
    gap: 15px;
}
.progress-circle {
    width: 80px;
    height: 80px;
    position: relative;
    flex-shrink: 0;
}
.progress-circle-bg, .progress-circle-fg {
    fill: none;
    stroke-width: 8;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}
.progress-circle-bg { stroke: var(--bg-color); }
.progress-circle-fg { transition: stroke-dashoffset 0.8s ease-out, stroke 0.5s ease-out; }
.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.6em;
    font-weight: 600;
    color: var(--text-color);
}
.score-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.os-name {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--heading-color);
    margin-bottom: 4px;
}
.open-rate {
    font-size: 0.95em;
    color: var(--secondary-text-color);
}
.score-analysis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}
.analysis-section h5 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1em;
    color: var(--heading-color);
}
.analysis-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}
.analysis-list li {
    font-size: 0.9em;
    color: var(--secondary-text-color);
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}
.analysis-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.analysis-section.positive li::before { content: '✓'; color: #2ecc71; background: none; font-weight: bold; left: -2px; top: 0; }
.analysis-section.recommendation li::before { content: '💡'; background: none; left: -4px; top: 0; }

/* 메인 AI 개선 제안 목록 스타일 */
#recommendations-by-ai .analysis-list {
    background-color: var(--bg-color);
    border-radius: 8px;
    padding: 20px;
}

#recommendations-by-ai .analysis-list li::before {
    content: '💡';
    background: none;
    left: 0;
}

/* --- 다른 초안 (아코디언) --- */
#other-drafts-container { margin-top: 40px; display: none; }
.draft-accordion-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}
.draft-accordion-item.active .draft-accordion-header {
    border-bottom: 1px solid var(--border-color);
}
.draft-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    cursor: pointer;
    background-color: var(--history-hover-bg);
    transition: background-color 0.2s;
}
.draft-accordion-header:hover {
    background-color: var(--bg-color);
}
.draft-title {
    font-weight: 600;
    color: var(--heading-color);
}
.draft-actions { display: flex; align-items: center; gap: 15px; }
.btn-secondary { background-color: transparent; color: #3498db; border: 1px solid #3498db; padding: 5px 12px; font-size: 13px; font-weight: 500; }
.btn-secondary:hover { background-color: #eaf2f8; }
.chevron-icon { transition: transform 0.3s ease; color: var(--secondary-text-color); }
.draft-accordion-item.active .chevron-icon { transform: rotate(180deg); }
.draft-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    background-color: var(--container-bg-color);
    padding: 0 15px;
}
.draft-accordion-item.active .draft-accordion-body {
    max-height: 500px;
    padding: 15px;
    transition: max-height 0.4s ease-in, padding 0.4s ease-in;
}
.draft-accordion-body p { margin-top: 0; margin-bottom: 15px; line-height: 1.7; }

/* --- AI 추천 키워드 --- */
#suggested-keywords-container { margin-top: 40px; display: none; }
.keyword-tags-list { display: flex; flex-wrap: wrap; gap: 10px; }
.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: var(--tag-bg-color);
    color: var(--tag-text-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--tag-border-color);
}
.keyword-tag:hover {
    background-color: var(--tag-hover-bg-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.keyword-tag svg { width: 14px; height: 14px; stroke-width: 2.5; }

/* ------------------- */
/* 6. 사이드바 및 이력  */
/* ------------------- */
.sidebar-container {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
}
.history-panel {
    background: var(--history-hover-bg);
    padding: 15px 5px 15px 15px;
    border-radius: 8px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    padding: 5px 15px 15px 5px;
    margin-bottom: 10px;
    background-color: var(--history-hover-bg);
    position: sticky;
    top: -15px;
    z-index: 10;
}
.history-header h2 {
    margin: 0;
    font-size: 1.2em;
    color: var(--heading-color);
}
.history-close-btn {
    display: none; /* 기본적으로 숨김 */
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    padding: 5px;
    color: var(--secondary-text-color);
    cursor: pointer;
    z-index: 11; /* 헤더 위에 위치 */
}
.history-close-btn:hover {
    background-color: transparent; /* 마우스를 올려도 배경색이 없도록 설정 */
    opacity: 0.7; /* 부드러운 피드백 효과 */
}
.history-controls { display: flex; gap: 8px; width: 100%; margin-top: 10px; }
#historySearchInput { flex-grow: 1; padding: 8px 12px; border-radius: 4px; font-size: 14px; min-width: 0; }
.clear-history-btn { background: none; border: 1px solid #e74c3c; color: #e74c3c; padding: 3px 10px; font-size: 12px; border-radius: 4px; cursor: pointer; transition: background-color 0.2s, color 0.2s; flex-shrink: 0; }
.clear-history-btn:hover { background-color: #e74c3c; color: white; }

.history-item {
    background-color: var(--container-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    margin-right: 10px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease-in-out;
    overflow: hidden;
}
.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
    border-color: #ccc;
}
.history-item.active {
    border-left: 4px solid #3498db;
    background-color: #f8faff; /* 다크모드 대응 필요 시 변수 사용 */
    padding-left: 12px;
}
.history-item-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s ease-in-out;
}
.history-item:hover .history-item-actions {
    opacity: 1;
    transform: translateX(0);
}
.history-item-action-btn {    
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    display: flex;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color); /* 아이콘 색상이 배경과 대비되도록 변경 */
    transition: background-color 0.2s;
}
.history-item-action-btn:hover {
    background-color: var(--history-action-btn-hover-bg);
}
.history-item-action-btn.copied {
    background-color: #d4edda;
    color: #155724;
}
.history-item-action-btn svg {
    width: 14px;
    height: 14px;
}
.history-item-title {
    font-weight: 600;
    color: #34495e;
    font-size: 0.95em;
    line-height: 1.4;
    padding-right: 60px; /* 버튼 공간 확보 */
}
.history-item-body {
    font-size: 0.9em;
    color: var(--secondary-text-color);
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}
.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    color: var(--secondary-text-color);
}
.meta-item svg {
    width: 14px;
    height: 14px;
    color: var(--secondary-text-color);
    flex-shrink: 0;
}
.history-date-header {
    margin-top: 20px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
    font-size: 1em;
    color: var(--heading-color);
    font-weight: 600;
}
#history-list .history-date-header:first-child {
    margin-top: 0;
}

/* ------------------- */
/* 7. 기타 및 광고  */
/* ------------------- */
.ad-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.ad-container .content-ad {
    flex: 1;
    margin-bottom: 0;
}

.content-ad {
    padding: 15px;
    border-radius: 6px;
    text-align: left;
    font-size: 0.9em;
    position: relative;
    background-color: var(--ad-bg-color);
    border: 1px solid var(--ad-border-color);
}
.content-ad-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #adb5bd;
    color: white;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 4px;
    font-weight: bold;
}
.content-ad strong {
    display: block;
    margin-bottom: 5px;
    font-size: 1.1em;
}
.content-ad p {
    margin: 0 0 12px 0;
    line-height: 1.5;
}
.content-ad-link {
    display: inline-block;
    width: 100%;
    text-align: center;
    background-color: #3498db;
    color: white;
    padding: 8px 0;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.2s ease-in-out;
}
.content-ad-link:hover {
    background-color: #2980b9;
}
.theme-switch-wrapper {
    display: flex;
    align-items: center;
}
.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 48px;
    margin-left: 15px;
    margin-right: 15px;
}
.theme-switch input { display:none; }
.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    background-color: #fff;
    bottom: 4px;
    content: "";
    height: 16px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 16px;
    border-radius: 50%;
}
input:checked + .slider { background-color: #3498db; }
input:checked + .slider:before { transform: translateX(24px); }

/* ------------------- */
/* 8. 반응형 디자인 */
/* ------------------- */
@media (max-width: 1024px) {
    .main-wrapper { flex-direction: column; }
    .sidebar-container {
        width: 100%;
        position: static;
        height: auto;
        max-height: 400px;
        align-self: stretch;
    }
}

@media (max-width: 768px) {
    .ad-container {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 15px;
    }

    .main-wrapper { padding: 1px; }
    .container { padding: 1px; }
    h1 { font-size: 1.8em; }

    .header-buttons {
        position: relative;
        z-index: 1001;
    }

    /* 이력 패널이 열렸을 때 버튼이 패널 뒤로 가도록 z-index를 초기화합니다. */
    body.history-open .header-buttons {
        z-index: auto;
    }

    .advanced-settings-section, .datetime-picker {
        flex-direction: column;
        gap: 15px;
    }
    .score-card-header, .score-analysis {
        flex-direction: column;
        text-align: center;
        grid-template-columns: 1fr;
    }
    .score-info { align-items: center; }

    /* 모바일용 이력 패널 슬라이드 */
    .sidebar-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
    }
    .sidebar-container.visible {
        pointer-events: auto;
        opacity: 1;
    }
    body.history-open {
        overflow: hidden;
    }
    .history-panel {
        position: absolute;
        top: 0;
        right: 0;
        width: 85%;
        max-width: 320px;
        height: 100%;
        box-shadow: -2px 0 8px rgba(0,0,0,0.15);
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
    }
    .sidebar-container.visible .history-panel {
        transform: translateX(0);
    }
    .history-toggle-btn, .history-close-btn {
        display: block; /* 모바일에서 버튼을 다시 보이게 합니다. */
    }
    .history-header {
        padding-top: 50px;
    }
    
}