:root {
    --bg: #282c34;
    --surface: #3a404a;
    --surface-2: #4b5263;
    --surface-hover: #5a606b;
    --surface-active: #606880;
    --border: #5a606b;

    --text: #abb2bf;
    --text-muted: #8b939e;

    --accent: #61afef;
    --accent-hover: #528fcc;

    --danger: #e06c75;
    --danger-hover: #be5046;

    --success: #98c379;
    --success-hover: #82b366;

    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

body {
    font-family: sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    background-color: var(--bg); /* Dark background */
    color: var(--text); /* Light text color */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.container {
    background-color: var(--surface); /* Slightly lighter dark background for container */
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow); /* More prominent shadow */
    width: 100%;
    max-width: 700px;
    position: relative; /* 添加相对定位，用于 GitHub 按钮定位 */
}

h1, h2 {
    color: var(--accent); /* Accent color for headings */
    margin: 0;
    text-align: center;
}

h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
}

.app-title {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.app-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.header-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
    gap: 10px;
}

#fileInput {
    display: none; /* 隐藏默认的文件输入框 */
}

.file-list-section {
    margin-bottom: 20px;
}

#fileList {
    list-style: none;
    padding: 0;
    border: 1px solid var(--border); /* Darker border */
    border-radius: var(--radius);
    max-height: 450px; /* Increased height */
    overflow-y: auto;
    margin: 0;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2) inset;
}

#fileList li {
    background-color: var(--surface-2); /* Darker background for list items */
    color: var(--text); /* Light text color */
    padding: 10px;
    margin-bottom: 5px;
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: background-color 0.3s ease;
    display: flex; /* Use flexbox for layout */
    align-items: center; /* Vertically align items */
    justify-content: space-between; /* Space out content */
    gap: 12px;
    position: relative; /* 添加相对定位，用于右键提示 */
    touch-action: auto;
    -webkit-tap-highlight-color: transparent; /* 移除iOS点击高亮 */
    user-select: none; /* 防止文本选择 */
    -webkit-user-select: none;
    -webkit-touch-callout: none; /* 防止iOS显示复制等菜单 */
}

#fileList li:active {
    background-color: var(--surface-active); /* 长按时背景色变化 */
    opacity: 0.8; /* 长按时透明度变化 */
}

/* 移动端拖拽样式 */
#fileList li.touch-dragging {
    opacity: 0.6;
    background-color: #5a6273;
    transform: scale(1.02);
    z-index: 10;
}

#fileList li.touch-over {
    border-top: 2px solid var(--accent);
}

/* 拖拽样式 */
#fileList li.dragging {
    background-color: #5a6273;
    opacity: 0.7;
}

#fileList li.dragover {
    border-top: 2px solid var(--accent);
}

#fileList li:hover {
    background-color: var(--surface-hover); /* Slightly lighter dark on hover */
}

#fileList li .file-info {
    flex-grow: 1; /* Allow file info to take up space */
    display: flex;
    align-items: center;
    min-width: 0;
}

#fileList li .file-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delete-file-button {
    flex-shrink: 0;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--danger);
    cursor: pointer;
    padding: 4px 10px;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.delete-file-button svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.delete-file-button:hover,
.delete-file-button:focus-visible {
    background-color: rgba(224, 108, 117, 0.12);
    border-color: var(--danger);
    color: #ffffff;
    outline: none;
}

#mergedFileName {
    padding: 8px;
    border: 1px solid var(--border); /* Darker border */
    border-radius: var(--radius-sm);
    background-color: var(--surface); /* Dark background */
    color: var(--text); /* Light text */
    flex-grow: 1;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.icon-button svg {
    fill: currentColor;
    transition: fill 0.3s ease;
}

.icon-button:hover {
    color: var(--accent-hover);
}

#clearAllButton {
    color: var(--danger);
}

#clearAllButton:hover {
    color: var(--danger-hover);
}

#mergeButton {
    color: var(--success);
}

#mergeButton:hover {
    color: var(--success-hover);
}

.action-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 15px;
    gap: 10px;
}

.filename-container {
    position: relative;
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.encoding-panel {
    position: relative;
}

.encoding-panel.is-open .icon-button {
    color: var(--accent-hover);
}

.encoding-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 140px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    box-shadow: var(--shadow);
    z-index: 20;
}

.encoding-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.encoding-option:hover,
.encoding-option:focus-visible {
    background-color: var(--surface-hover);
    outline: none;
}

.encoding-check {
    width: 1em;
    color: var(--success);
    visibility: hidden;
}

.encoding-option.is-active .encoding-check {
    visibility: visible;
}

.encoding-label {
    flex: 1;
}

.input-logo {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.action-section input[type="text"] {
    flex-grow: 1;
    margin: 0;
    padding-right: 30px; /* 为logo留出空间 */
}

.github-button {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    z-index: 10;
    border-radius: 50%;
    padding: 5px;
    background-color: transparent;
    color: var(--accent);
}

.github-button svg {
    fill: currentColor;
    transition: fill 0.3s ease;
}

.github-button:hover {
    transform: scale(1.1);
    background-color: rgba(0, 0, 0, 0.2);
}

.github-button:hover {
    color: #ffffff;
}

@media (max-width: 600px) {
    .action-section {
        flex-wrap: wrap;
        justify-content: center;
    }

    .filename-container {
        order: 1;
        width: 100%;
    }

    .encoding-panel {
        order: 2;
        margin-left: auto;
    }

    .github-button {
        top: 10px;
        right: 10px;
    }
    
    .github-button svg {
        height: 24px;
        width: 24px;
    }
}