:root {
    --bg-primary: #2b2d31;
    --bg-secondary: #313338;
    --text-primary: #f2f3f5;
    --accent-color: #727cd4;
    --progress-bg: #444b54;
    --container-shadow: rgba(0, 0, 0, 0.3);
    --status-shadow: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --text-primary: #333333;
    --accent-color: #727cd4;
    --progress-bg: #e0e0e0;
    --container-shadow: rgba(0, 0, 0, 0.1);
    --status-shadow: rgba(0, 0, 0, 0.1);
}

/* Prevent flash of unstyled content */
html {
    visibility: hidden;
}

html.theme-loaded {
    visibility: visible;
}

body {
    font-family: 'Pretendard Variable', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1 {
    font-family: 'Pretendard Variable', sans-serif;
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-primary);
    transition: color 0.3s ease;
    text-align: center;
    letter-spacing: 1px;
}

.drop-zone-container {
    width: 100%;
    height: 140px;
    position: relative;
    margin-bottom: 15px;
}

.drop-zone {
    background-color: var(--bg-primary);
    padding: 40px;
    border-radius: 44px;
    text-align: center;
    width: 100%;
    cursor: pointer;
    transition: 0.2s ease;
    font-size: 1em;
    font-weight: 600;
    color: var(--accent-color);
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
}

.drop-zone:hover, .drop-zone.dragover {
    background-color: var(--accent-color);
    color: #f1f1f1;
    font-size: 1.02em;
    transform: scale(1.005);
}

.drop-zone-subtext {
    font-size: 0.85em;
    margin-top: 8px;
    opacity: 0.8;
}

.dropZone_under {
    font-size: 0.8em;
    color: var(--accent-color);
    opacity: 70%;
}

.dropZone_under:hover, .drop-zone.dragover {
    font-size: 0.8em;
    color: #f1f1f1;;
    opacity: 70%;
}

.drop-zone-text {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
}

.container {
    width: 100%;
    max-width: 1000px;
    background-color: var(--bg-secondary);
    border-radius: 44px;
    padding: 15px;
    box-shadow: 0 10px 30px var(--container-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    box-sizing: border-box;
    height: auto;
    min-height: 0;
    position: relative;
}

.theme-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.theme-toggle {
    position: relative;
    width: 60px;
    height: 30px;
    background-color: var(--bg-primary);
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0 2px;
    box-shadow: inset 0 2px 4px var(--container-shadow);
    transition: all 0.3s ease;
}

.theme-label {
    font-size: 0.7em;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.theme-toggle-slider {
    width: 26px;
    height: 26px;
    background-color: var(--accent-color);
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center;
}

.theme-toggle[data-theme="light"] .theme-toggle-slider {
    transform: translateX(32px);
}

.theme-toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    filter: brightness(0) invert(1);
    transition: transform 0.4s ease;
}

.theme-toggle[data-theme="light"] .theme-toggle-slider::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'%3E%3C/circle%3E%3Cline x1='12' y1='1' x2='12' y2='3'%3E%3C/line%3E%3Cline x1='12' y1='21' x2='12' y2='23'%3E%3C/line%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'%3E%3C/line%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'%3E%3C/line%3E%3Cline x1='1' y1='12' x2='3' y2='12'%3E%3C/line%3E%3Cline x1='21' y1='12' x2='23' y2='12'%3E%3C/line%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'%3E%3C/line%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'%3E%3C/line%3E%3C/svg%3E");
}

.save-button-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.save-button {
    background-color: var(--bg-primary);
    border: none;
    padding: 8px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 1.2em;
    box-shadow: inset 0 2px 4px var(--container-shadow);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.save-button:hover {
    background-color: var(--progress-bg);
}

.history-controls {
    position: absolute;
    top: -160px;
    right: 0;
    background-color: var(--bg-secondary);
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 4px 6px var(--container-shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.history-controls.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.save-checkbox {
    font-family: 'Pretendard Variable', sans-serif;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: var(--text-primary);
    margin-top: 8px;
}

.save-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-primary);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    position: relative;
    background-color: transparent;
    transition: all 0.2s ease;
    transform: translateY(-2px);
    margin: 0;
}

.save-checkbox input[type="checkbox"]:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.save-checkbox input[type="checkbox"]:checked::before {
    content: "✓";
    position: absolute;
    color: white;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.save-checkbox label {
    cursor: pointer;
    user-select: none;
    position: relative;
    display: inline-block;
    width: 180px;
    height: 24px;
}

.checkbox-text {
    position: absolute;
    left: 0;
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    transition: opacity 0.2s ease;
}

.checkbox-text.checked {
    opacity: 0;
}

.checkbox-text.unchecked {
    opacity: 1;
}

.save-checkbox input[type="checkbox"]:checked ~ label .checkbox-text.checked {
    opacity: 1;
}

.save-checkbox input[type="checkbox"]:checked ~ label .checkbox-text.unchecked {
    opacity: 0;
}

.history-button {
    background-color: var(--accent-color);
    font-family: 'Pretendard Variable', sans-serif;
    font-weight: 700;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    width: 100%;
}

.history-button:hover {
    background-color: #5662be;
}

.history-container {
    width: 100%;
    margin-top: 20px;
    max-width: 1000px;
    background-color: var(--bg-secondary);
    border-radius: 44px;
    padding: 20px;
    box-shadow: 0 10px 30px var(--container-shadow);
    display: none;
    box-sizing: border-box;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.history-container.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.history-content {
    width: 100%;
    max-width: 800px;
    padding: 40px;
    box-sizing: border-box;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--bg-primary);
    border-radius: 20px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    font-family: 'Pretendard Variable', sans-serif;
    color: var(--text-primary);
}

.history-item span {
    font-family: 'Pretendard Variable', sans-serif;
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 600;
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--container-shadow);
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0; /* Prevents overflow with long filenames */
}

.history-item-filename {
    font-family: 'Pretendard Variable', sans-serif;
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 800;
    margin: 0;
}

.history-item-date {
    font-family: 'Pretendard Variable', sans-serif;
    color: var(--text-primary);
    font-size: 0.9em;
    opacity: 0.8;
}

.history-actions {
    display: flex;
    gap: 10px;
    margin-left: 20px;
}

.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.history-item .button-group {
    display: flex;
    gap: 8px;
}

.download-btn,
.share-btn {
    background-color: var(--accent-color);
    color: white;
    padding: 0 15px;
    height: 30px;
    border: none;
    border-radius: 33px;
    cursor: pointer;
    font-size: 0.8em;
    font-family: 'Pretendard Variable', sans-serif;
    font-weight: 800;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.download-btn:hover,
.share-btn:hover {
    background-color: #6066e6;
    transform: scale(1.05);
}

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

.shared-content {
    width: 100%;
    background-color: var(--bg-primary);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    overflow-x: auto;
}

.shared-content pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
    font-family: 'Pretendard Variable', monospace;
}

.clear-history-button {
    font-family: 'Pretendard Variable', sans-serif;
    font-weight: 700;
    background-color: #dc3545;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 8px;
}

.clear-history-button:hover {
    background-color: #c82333;
}

.status-list {
    width: 100%;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.status-item {
    background-color: var(--bg-primary);
    border-radius: 33px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px var(--status-shadow);
    width: 100%;
    box-sizing: border-box;
    opacity: 1;
    transform: scale(1);
}

.progress-container {
    flex-grow: 1;
    background-color: var(--progress-bg);
    border-radius: 12px;
    position: relative;
    height: 30px;
    margin-right: 10px;
    font-size: 1.1em;
    font-weight: 400;
}

.progress-bar {
    background-color: var(--accent-color);
    height: 100%;
    border-radius: 32px;
    width: 0%;
    transition: width 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}

.progress-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9em;
    color: var(--text-primary);
    font-weight: 400;
    font-family: 'Pretendard Variable', sans-serif;
    font-weight: 700;
}

.tooltip {
    position: fixed;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9em;
    font-family: 'Pretendard Variable', sans-serif;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 6px var(--container-shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
    filter: brightness(1.1);
}

.tooltip.visible {
    opacity: 0.8;
}

.history-limit-text {
    font-size: 0.6em;
    color: var(--text-primary);
    opacity: 0.7;
    font-weight: normal;
    margin-left: 8px;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
        margin-bottom: 15px;
    }

    .status-item {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
    }

    .progress-container {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }

    .theme-container {
        top: 10px;
        right: 10px;
    }
    
    .history-controls {
        right: 20px;
        top: 60px;
    }
}

/* Action Popups Container */
#actionPopupsContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column; /* HTML상 먼저 선언된 spellcheck 버튼이 위에 오도록 */
    gap: 10px; /* 버튼 사이 간격 */
    z-index: 1000;
}

/* Shared styles for popup buttons */
#popupMessage,
#spellcheckPopupMessage {
    background-color: var(--popup-bg-color);
    color: var(--text-primary);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-family: 'Pretendard Variable', sans-serif;
    font-size: 1rem;
    transition: background-color 0.3s, color 0.3s;
    text-align: center;
}

#popupMessage:hover,
#spellcheckPopupMessage:hover {
    background-color: var(--accent-color);
    color: var(--text-primary);
}

#popupMessage p,
#spellcheckPopupMessage p {
    margin: 0;
}

/* 다크/라이트 모드에 따른 팝업 색상 변수 */
:root[data-theme="light"] {
    --popup-bg-color: #f0f0f0;
    --popup-text-color: #333; /* 이 변수는 현재 버튼 스타일에 직접 사용되지는 않지만, 유지합니다. */
    --popup-hover-bg-color: #e0e0e0; /* 이 변수는 현재 버튼 스타일에 직접 사용되지는 않지만, 유지합니다. */
}

:root[data-theme="dark"] {
    --popup-bg-color: #333;
    --popup-text-color: #fff; /* 이 변수는 현재 버튼 스타일에 직접 사용되지는 않지만, 유지합니다. */
    --popup-hover-bg-color: #555; /* 이 변수는 현재 버튼 스타일에 직접 사용되지는 않지만, 유지합니다. */
}