/* ==========================================
   公共样式 - 公益配置大全
   所有页面通过 <link rel="stylesheet" href="common.css"> 引入
   ========================================== */

/* 基础重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

/* CSS 变量（亮色模式） */
:root {
    --bg: #f5f7fb;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --text: #172033;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-bg: #eff6ff;
    --success: #16a34a;
    --success-hover: #15803d;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fee2e2;
    --warning: #ea580c;
    --warning-light: #fff7ed;
    --info: #0891b2;
    --info-light: #ecfeff;
    --purple: #7c3aed;
    --purple-light: #f5f3ff;
    --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    --shadow-md: 0 4px 6px rgba(15,23,42,.05), 0 2px 4px rgba(15,23,42,.03);
    --shadow-lg: 0 10px 25px rgba(15,23,42,.08);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: .2s ease;
}

/* 暗色模式 */
.dark-mode {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --border: #334155;
    --border-hover: #475569;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,.15);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.2);
    --primary-light: #1e3a5f;
    --primary-bg: #172554;
    --success-light: #052e16;
    --danger-light: #450a0a;
    --warning-light: #431407;
    --purple-light: #2e1065;
    --info-light: #083344;
}

/* 页面基础 */
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    padding: 16px;
    transition: background var(--transition), color var(--transition);
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout Shell ===== */
.shell {
    max-width: 680px;
    margin: 0 auto;
}

/* ===== Header Bar ===== */
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.header .back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 18px;
    text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0;
}
.header .back:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.header .title {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ===== Card ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    transition: var(--transition);
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    padding: 0 18px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    touch-action: manipulation;
    user-select: none;
    text-decoration: none;
    color: var(--text);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-outline {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0 10px;
}
.btn-ghost:hover:not(:disabled) { background: var(--primary-light); color: var(--primary); }

.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { min-height: 48px; padding: 0 24px; font-size: 15px; border-radius: 12px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-group .btn { flex: 1; min-width: 0; }

/* ===== Input ===== */
.input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text);
    background: var(--bg-input);
    outline: none;
    transition: var(--transition);
}
.input::placeholder { color: var(--text-muted); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.dark-mode .input { background: var(--bg); }

textarea.input {
    min-height: 100px;
    padding: 12px 14px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

/* ===== Upload Area ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-input);
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-bg);
}
.upload-area .icon { font-size: 36px; margin-bottom: 8px; }
.upload-area .text { font-size: 14px; color: var(--text-secondary); }
.upload-area .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== Tags / Chips ===== */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: var(--primary-light);
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.tag:hover { opacity: .8; }
.tag.active { background: var(--primary); color: #fff; }

/* ===== Badge ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: #fff;
    background: var(--text);
    box-shadow: var(--shadow-lg);
    animation: toastIn .3s ease, toastOut .3s ease 2.2s forwards;
    pointer-events: auto;
    word-break: break-all;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-20px); } }

/* ===== Modal / Dialog ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn .2s ease;
}
.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 24px;
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp .25s ease;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px; border: none; background: transparent;
    font-size: 20px; cursor: pointer; color: var(--text-muted);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }
.modal-footer { margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Progress ===== */
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar .fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width .3s ease;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .text { font-size: 14px; }

/* ===== Result / Preview Area ===== */
.result-area {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.7;
    word-break: break-all;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}
.result-line {
    padding: 8px 10px;
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    background: var(--bg-card);
    margin-bottom: 6px;
    font-size: 13px;
    font-family: inherit;
    word-break: break-all;
}

/* ===== Utility ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ===== Footer ===== */
.footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: 24px 0 12px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
    body { padding: 10px; }
    .shell { max-width: 100%; }
    .card { padding: 12px; }
    .header .title { font-size: 16px; }
}
