/* ===== 首页布局 ===== */
.home-layout {
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

#setup-panel {
    width: 100%;
    max-width: 600px;
    text-align: center;
}

/* ===== Tab 组 ===== */
.tab-group {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 20px;
}
.tab-btn {
    flex: 1;
    padding: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    transition: 0.2s;
    border: none;
    background: transparent;
}
.tab-text-short { display: none; }
.tab-btn.active {
    background: #fff;
    color: var(--primary-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.input-area { display: none; }
.input-area.active { display: block; animation: fadeIn 0.2s; }

/* ===== 上传区域 ===== */
.upload-zone {
    border: 2px dashed #e2e8f0;
    border-radius: 16px;
    padding: 40px 20px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
}
.upload-zone:hover { border-color: var(--primary-color); background: #f0f7ff; }
.upload-zone.drag-over { border-color: var(--primary-color); background: #e0edff; }
.upload-icon { font-size: 32px; margin-bottom: 10px; }
.upload-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 5px; }
.upload-hint { font-size: 12px; color: #94a3b8; }

/* ===== 粘贴框 ===== */
.paste-box {
    width: 100%;
    height: 200px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    resize: vertical;
    font-family: monospace;
    font-size: 13px;
    background: #f8fafc;
    margin-bottom: 10px;
}
.paste-box:focus { outline: none; border-color: var(--primary-color); background: #fff; }

/* ===== Sub Tab ===== */
.sub-tab {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
}
.sub-tab-btn {
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
}
.sub-tab-btn.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f7ff;
    box-shadow: 0 2px 4px rgba(78,110,242,0.1);
}

/* ===== 预设卡片 ===== */
.preset-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}
.preset-card {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    text-align: left;
}
.preset-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(78,110,242,0.15);
    transform: translateY(-2px);
}
.preset-card.selected {
    border-color: var(--primary-color);
    background: #f0f7ff;
}
.preset-card-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; color: var(--text-main); }
.preset-card-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.preset-card-example-btn {
    display: inline-block;
    padding: 4px 10px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 11px;
    color: var(--primary-color);
    cursor: pointer;
    margin-top: 4px;
    transition: 0.2s;
}
.preset-card-example-btn:hover { background: #e0edff; }

/* ===== 自定义对话框 ===== */
.dialog-overlay { z-index: 2000; }

.dialog-box {
    background: white;
    border-radius: 18px;
    width: 90%;
    max-width: 380px;
    padding: 28px 24px 20px;
    animation: scaleIn 0.25s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    text-align: center;
}
.dialog-icon { font-size: 36px; margin-bottom: 12px; }
.dialog-title { font-size: 17px; font-weight: 700; color: var(--text-main); margin-bottom: 8px; }
.dialog-message { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 24px; }
.dialog-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.dialog-btn {
    flex: 1;
    min-width: 140px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.dialog-btn-cancel { background: #f1f5f9; color: #6b7280; }
.dialog-btn-cancel:hover { background: #e2e8f0; }
.dialog-btn-confirm { background: var(--primary-color); color: white; }
.dialog-btn-confirm:hover { background: var(--primary-hover); }
.dialog-btn-danger { background: #ef4444; color: white; }
.dialog-btn-danger:hover { background: #dc2626; }
.dialog-prompt-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.dialog-prompt-input:focus { border-color: var(--primary-color); }

/* ===== 模态框 ===== */
.modal-overlay { animation: fadeIn 0.2s; }

.modal-content {
    background: white;
    border-radius: 18px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 0;
    animation: scaleIn 0.3s;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    border-radius: 18px 18px 0 0;
}
.modal-title { font-size: 18px; font-weight: 600; color: var(--text-main); }
.modal-close {
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: 0.2s;
}
.modal-close:hover { background: #f5f5f5; }
.modal-body { padding: 20px; }

/* ===== 示例区域 ===== */
.example-section {
    background: #f8fafc;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}
.example-title { font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 8px; }
.example-code {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-x: auto;
}
.copy-example-btn {
    margin-top: 10px;
    padding: 10px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: 0.2s;
    white-space: nowrap;
}
.copy-example-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(78,110,242,0.3);
}

/* ===== 自定义格式 ===== */
.custom-format-container { text-align: left; }
.custom-mode-switch {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #f8fafc;
    padding: 8px;
    border-radius: 10px;
}
.mode-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid transparent;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: 0.2s;
    text-align: center;
}
.mode-btn.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f7ff;
}
.mode-desc { font-size: 11px; display: block; margin-top: 4px; font-weight: normal; }

.custom-simple-mode, .custom-advanced-mode { display: none; }
.custom-simple-mode.active, .custom-advanced-mode.active { display: block; }

.simple-format-builder, .advanced-format-editor {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
}

.format-field { margin-bottom: 16px; }
.format-field label {
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-main);
}
.help-icon {
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px; height: 16px;
    background: #e2e8f0;
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 11px;
    cursor: help;
}
.format-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    transition: 0.2s;
}
.format-field input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(78,110,242,0.1);
}
.format-field-help { font-size: 11px; color: #94a3b8; margin-top: 4px; line-height: 1.4; }

.quick-templates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.template-chip {
    padding: 6px 10px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
}
.template-chip:hover { border-color: var(--primary-color); color: var(--primary-color); }

.regex-input {
    font-family: 'Courier New', monospace !important;
    background: #ffffff !important;
    color: var(--text-main) !important;
    border: 1px solid #e2e8f0 !important;
}
.regex-input:focus { border-color: var(--primary-color) !important; box-shadow: 0 0 0 3px rgba(78,110,242,0.1); }

/* ===== 已保存格式 ===== */
.saved-formats { margin-top: 20px; }
.saved-formats-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-main); }
.saved-format-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: 0.2s;
}
.saved-format-item:hover { border-color: #cbd5e1; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.saved-format-info { flex: 1; }
.saved-format-name { font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 2px; }
.saved-format-meta { font-size: 11px; color: var(--text-secondary); }
.saved-format-actions { display: flex; gap: 6px; }

/* ===== 图标按钮 ===== */
.icon-btn {
    padding: 6px 10px;
    border: none;
    background: #f1f5f9;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: 0.2s;
}
.icon-btn:hover { background: #e2e8f0; color: var(--text-main); }
.icon-btn.primary { background: var(--primary-color); color: white; }
.icon-btn.primary:hover { background: var(--primary-hover); }

/* ===== 错误消息 ===== */
.error-msg {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 13px;
    text-align: left;
    display: none;
}

/* ===== 操作按钮 ===== */
.action-btn {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 10px;
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid #e2e8f0; color: #6b7280; margin-top: 8px; }
.btn-outline:hover { border-color: #6b7280; color: var(--text-main); background: #f8fafc; }

/* ===== 准备就绪 ===== */
#ready-panel {
    display: none;
    text-align: center;
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.3s ease;
}
.file-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}
.shuffle-options {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    text-align: left;
}
.shuffle-options label { display: flex; align-items: center; margin: 8px 0; cursor: pointer; font-size: 14px; color: var(--text-secondary); }
.shuffle-options input[type="checkbox"] { margin-right: 8px; width: 16px; height: 16px; accent-color: var(--primary-color); }

/* ===== 设置按钮 ===== */
.settings-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.2s, border-color 0.2s;
    z-index: 2000;
    user-select: none;
    touch-action: none;
}
.settings-fab:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    border-color: var(--primary-color);
}
.settings-fab.dragging {
    cursor: grabbing;
    box-shadow: 0 8px 25px rgba(0,0,0,0.18);
    opacity: 0.9;
    transition: none !important;
    will-change: transform;
}
.settings-fab.snapping {
    transition: right 0.3s ease, bottom 0.3s ease, box-shadow 0.2s, border-color 0.2s;
}
.settings-fab svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.settings-fab:hover svg { color: var(--primary-color); }

/* ===== 设置面板 ===== */
.settings-panel { z-index: 1600; }

.settings-content {
    background: white;
    border-radius: 18px;
    width: 90%;
    max-width: 460px;
    max-height: 85vh;
    overflow-y: auto;
    animation: scaleIn 0.3s;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.settings-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    border-radius: 18px 18px 0 0;
    z-index: 1;
}
.settings-header-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-body { padding: 20px 24px; }

.setting-group { margin-bottom: 24px; }
.setting-group-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f8f8f8;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 14px; font-weight: 500; color: var(--text-main); }
.setting-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== Toggle switch ===== */
.toggle-switch {
    position: relative;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #e2e8f0;
    border-radius: 26px;
    cursor: pointer;
    transition: 0.3s;
}
.toggle-slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary-color); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ===== Hotkey ===== */
.hotkey-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f8f8f8;
}
.hotkey-row:last-child { border-bottom: none; }
.hotkey-label { font-size: 13px; color: var(--text-main); font-weight: 500; }
.hotkey-input-wrapper { display: flex; align-items: center; gap: 6px; }
.hotkey-input {
    width: 70px;
    padding: 6px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    background: #f8fafc;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}
.hotkey-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(78,110,242,0.12);
}
.hotkey-input.recording {
    border-color: #f59e0b;
    background: #fffbeb;
    animation: pulse 1s infinite;
}
.hotkey-reset-btn {
    padding: 4px 8px;
    border: none;
    background: #f1f5f9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    transition: 0.2s;
}
.hotkey-reset-btn:hover { background: #e2e8f0; }

.hotkeys-disabled-overlay { position: relative; }
.hotkeys-disabled-overlay.disabled::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.6);
    border-radius: 8px;
    z-index: 1;
}

/* ===== 快捷键提示气泡 ===== */
.hotkey-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30,41,59,0.9);
    color: white;
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    z-index: 900;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    backdrop-filter: blur(4px);
}
.hotkey-hint.show { opacity: 1; }

/* ===== 内联样式提取 ===== */
.ai-entry-panel { text-align: center; padding: 40px 20px 20px; }
.ai-entry-icon { font-size: 48px; margin-bottom: 15px; }
.ai-entry-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
.ai-entry-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 25px; line-height: 1.6; }
.ai-entry-hint { margin-top: 15px; font-size: 12px; color: var(--text-secondary); }
.file-card-icon { color: var(--correct-text); font-size: 24px; margin-bottom: 8px; }
.file-card-title { font-weight: 600; margin-bottom: 4px; }
.file-card-desc { color: var(--text-secondary); font-size: 13px; }
.shuffle-title { font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
.analysis-label { font-weight: bold; margin-bottom: 5px; color: var(--text-main); }
.result-header-title { width: 100%; text-align: center; }
.score-unit { font-size: 14px; color: #999; }
.result-hint { font-size: 13px; color: var(--text-secondary); margin-bottom: 15px; }
.api-test-result { display: none; margin-top: 12px; padding: 12px; border-radius: 8px; font-size: 13px; line-height: 1.6; }
.api-hint { margin-top: 10px; font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
