/* ===== 全局变量 ===== */
:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #22222e;
    --bg-hover: #2a2a38;
    --border-color: #2e2e3e;
    --text-primary: #e4e4ed;
    --text-secondary: #9a9aae;
    --text-muted: #6a6a7e;
    --accent: #6366f1;
    --accent-hover: #7c7ff5;
    --accent-light: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    outline: none;
    transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: var(--mono); }
::selection { background: var(--accent-light); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a4e; }

/* ===== 布局 ===== */
#app {
    display: flex;
    height: 100vh;
    height: 100dvh; /* 移动端动态视口，解决地址栏收起/展开导致显示不全 */
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 100;
}
.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-group { margin-bottom: 8px; }
.nav-group-title {
    padding: 8px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    transition: all var(--transition);
    cursor: pointer;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
}
.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid var(--border-color); }
.privacy-badge {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}
.privacy-badge svg { flex-shrink: 0; margin-top: 1px; color: var(--success); }

/* ===== 主内容 ===== */
.main-content {
    flex: 1;
    min-width: 0; /* 防止内容撑破布局 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar-spacer { flex: 1; }
.mobile-menu-btn { display: none; margin-right: 12px; }
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
    overscroll-behavior: contain; /* 防止滚动穿透 */
}

/* ===== 工具面板 ===== */
.tool-panel { display: none; max-width: 900px; margin: 0 auto; }
.tool-panel.active { display: block; }
.tool-header { margin-bottom: 24px; }
.tool-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.tool-header p { color: var(--text-secondary); font-size: 13px; }

/* ===== 拖拽区域 ===== */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-secondary);
    margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.drop-zone svg { color: var(--text-muted); margin-bottom: 12px; transition: color var(--transition); }
.drop-zone:hover svg, .drop-zone.dragover svg { color: var(--accent); }
.drop-zone-text { font-size: 15px; margin-bottom: 6px; }
.drop-zone-text .link { color: var(--accent); font-weight: 600; }
.drop-zone-hint { font-size: 12px; color: var(--text-muted); }
.drop-zone-sm { padding: 24px; }

/* ===== 选项行 ===== */
.options-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}
.option-group { display: flex; flex-direction: column; gap: 6px; }
.option-group label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.option-group select, .option-group input[type="color"] { min-width: 140px; }

/* 透明背景等开关 */
.check-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}
.check-wrap input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
.option-hint { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* ===== 按钮 ===== */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--accent); }

/* ===== 滑块 ===== */
.range-wrap { display: flex; align-items: center; gap: 10px; }
.range-wrap input[type="range"] {
    -webkit-appearance: none;
    width: 140px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    border: none;
    padding: 0;
}
.range-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}
.range-value { font-size: 13px; color: var(--text-secondary); min-width: 60px; }

/* ===== 结果列表 ===== */
.result-list { display: flex; flex-direction: column; gap: 12px; }
.result-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color var(--transition);
}
.result-item:hover { border-color: var(--accent); }
.result-thumb {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}
.result-info { flex: 1; min-width: 0; }
.result-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.result-meta { font-size: 12px; color: var(--text-muted); }
.result-meta .saved { color: var(--success); font-weight: 600; }
.result-meta .increased { color: var(--danger); font-weight: 600; }

/* ===== 帧预览 ===== */
.frame-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.frame-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}
.frame-thumb img { width: 100%; height: 100%; object-fit: cover; }
.frame-thumb .frame-num {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 11px;
    color: #fff;
    background: rgba(0,0,0,0.6);
    padding: 1px 4px;
    border-radius: 3px;
}
.frame-thumb .frame-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition);
}
.frame-thumb:hover .frame-remove { opacity: 1; }

/* ===== 已选文件列表（缩略图固定小尺寸，绝不超出面板） ===== */
.file-list {
    display: none; /* 无文件时隐藏 */
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    max-width: 100%;
    overflow: hidden;
}
.file-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.file-list-title { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    min-width: 0;
}
/* 缩略图：固定 48x48，object-fit 裁剪填充，2K 照片也只显示小方图 */
.file-thumb-wrap {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-secondary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.file-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.file-thumb-icon { font-size: 20px; }
.file-info { flex: 1; min-width: 0; }
.file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-size { font-size: 12px; color: var(--text-muted); }
.file-remove {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: all var(--transition);
}
.file-remove:hover { background: var(--danger); color: #fff; }

/* ===== 文件信息条（单文件工具用） ===== */
.file-info-bar {
    padding: 10px 16px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-all;
}

/* ===== 进度条 ===== */
.progress-bar-wrap { margin: 16px 0; }
.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #a855f7);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}
.progress-text { font-size: 13px; color: var(--text-secondary); }

/* ===== 转换方向 ===== */
.convert-direction {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}
.direction-option { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.direction-option input { accent-color: var(--accent); }
.direction-option label { cursor: pointer; font-weight: 500; }

/* ===== 选项行(小) ===== */
.option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.hint-text { font-size: 12px; color: var(--text-muted); margin-left: auto; }

/* ===== 双文本框 ===== */
.dual-textarea { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.textarea-wrap { display: flex; flex-direction: column; gap: 6px; }
.textarea-wrap label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.textarea-wrap textarea { min-height: 120px; padding: 12px; line-height: 1.6; }

/* ===== Tab ===== */
.tool-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.tab-btn {
    padding: 8px 16px;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    font-weight: 500;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== 进制转换 ===== */
.base-converter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.base-field { display: flex; flex-direction: column; gap: 6px; }
.base-field label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.base-field input { font-family: var(--mono); }

/* ===== 哈希结果 ===== */
.hash-results { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.hash-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.hash-item label { font-size: 12px; font-weight: 600; color: var(--accent); min-width: 70px; }
.hash-value {
    flex: 1;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-all;
}
.hash-copy { flex-shrink: 0; }

/* ===== 货币转换 ===== */
.currency-converter {
    padding: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 24px;
}
.currency-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.currency-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 120px; }
.currency-field label { font-size: 12px; color: var(--text-secondary); }
.currency-result {
    margin-top: 24px;
    padding: 20px;
    background: var(--accent-light);
    border-radius: var(--radius);
    text-align: center;
}
.result-amount { font-size: 36px; font-weight: 700; color: var(--accent); }
.result-detail { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.currency-info { margin-top: 12px; text-align: right; font-size: 12px; color: var(--text-muted); }
.currency-table-wrap h3 {
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.badge {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 4px;
    font-weight: 600;
}
.currency-table { width: 100%; border-collapse: collapse; }
.currency-table th, .currency-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.currency-table th { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.currency-table td { font-size: 13px; }
.currency-table tbody tr:hover { background: var(--bg-hover); }
.currency-table .rate-value { font-family: var(--mono); }

/* ===== 颜色工具 ===== */
.color-tool { display: flex; gap: 24px; flex-wrap: wrap; }
.color-preview {
    width: 200px;
    height: 200px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}
.color-inputs { flex: 1; display: flex; flex-direction: column; gap: 16px; min-width: 300px; }
.color-field { display: flex; flex-direction: column; gap: 6px; }
.color-field label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

/* ===== 时间戳 ===== */
.timestamp-tool { display: flex; flex-direction: column; gap: 20px; max-width: 600px; }
.ts-field { display: flex; flex-direction: column; gap: 8px; }
.ts-field label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.ts-current {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.ts-current span { font-family: var(--mono); font-size: 18px; color: var(--accent); }
.ts-row { display: flex; gap: 8px; }
.ts-row input { flex: 1; }
.ts-row select { width: auto; }
.ts-output {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text-secondary);
    min-height: 44px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 13px;
    max-width: 360px;
    animation: toast-in 0.3s ease;
    border-left: 3px solid var(--accent);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== 响应式 ===== */
/* 移动端侧边栏遮罩（桌面端隐藏） */
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 150;
    }
    .sidebar-overlay.show { display: block; }
    .mobile-menu-btn { display: flex; align-items: center; }
    .dual-textarea { grid-template-columns: 1fr; }
    .base-converter-grid { grid-template-columns: 1fr; }
    .color-tool { flex-direction: column; }
    .color-preview { width: 100%; height: 150px; }
    .content-area {
        padding: 16px 16px 48px 16px; /* 底部留白，防止内容被裁切 */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .currency-row { flex-direction: column; }
    .options-row { flex-direction: column; align-items: stretch; }
    .option-group { width: 100%; }
    .option-group select, .option-group input { width: 100%; }
    /* 小屏结果项允许换行，防止溢出屏幕 */
    .result-item { flex-wrap: wrap; }
    .result-item .result-thumb { width: 48px; height: 48px; }
    .result-info { flex: 1 1 calc(100% - 60px); min-width: 0; }
    .result-item .btn { flex: 1 1 100%; justify-content: center; }
    /* 触屏没有 hover，移除按钮常显 */
    .frame-thumb .frame-remove { opacity: 1; }
    /* 表格横向可滚动 */
    .currency-table-wrap { overflow-x: auto; }
    textarea { max-width: 100%; }
    .toast-container { left: 16px; right: 16px; bottom: 16px; }
    .toast { max-width: 100%; }
}
