:root {
    --bg-body: #1a1a1a;
    --bg-panel: #262626;
    --bg-input: #333333;
    --text-main: #f0f0f0;
    --text-sub: #888888;
    --border: #3d3d3d;
    --accent: #4a90e2;
    --accent-hover: #357abd;
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
    --radius: 8px;
    --font-ui: "PingFang SC","Microsoft YaHei","Inter",sans-serif;
}
[data-theme="light"] {
    --bg-body: #f5f5f5;
    --bg-panel: #ffffff;
    --bg-input: #e0e0e0;
    --text-main: #333333;
    --text-sub: #666666;
    --border: #cccccc;
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
}
* {
    box-sizing: border-box;
    margin: 0; padding: 0; outline: none;
    -webkit-tap-highlight-color: transparent;
}
html {
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    overflow: hidden; height: 100%;
}
body {
    background: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100%; display: flex;
    flex-direction: column; overflow: hidden;
    transition: background 0.5s, color 0.5s;
}
.toolbar {
    height: 60px; background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 20px; flex-shrink: 0; z-index: 10;
    transition: background 0.5s, border-color 0.5s;
}
.brand-section { display: flex; align-items: center; }
.brand {
    font-weight: 600; font-size: 16px;
    display: flex; align-items: center; gap: 8px;
}
.controls-section { display: flex; gap: 10px; align-items: center; }
.divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.btn-upload, .btn-action, .btn-primary, .btn-icon {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 14px; border-radius: var(--radius);
    cursor: pointer; font-size: 13px;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.2s; white-space: nowrap;
}
.btn-icon { padding: 6px 8px; font-size: 16px; }
.btn-upload:hover, .btn-action:hover, .btn-icon:hover {
    background: var(--border);
}
.btn-primary {
    background: var(--accent); border-color: var(--accent);
    color: #fff; width: 100%; justify-content: center;
    margin-top: 16px; padding: 10px;
}
.btn-primary:hover { background: var(--accent-hover); }
.theme-btn i {
    display: inline-block;
    transition: transform 0.6s cubic-bezier(0.34,1.56,0.64,1);
}
.theme-btn.spin i { transform: rotate(360deg); }
.input-group {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 10px; display: flex;
    align-items: center; height: 32px; width: 200px;
}
.input-group i { color: var(--text-sub); margin-right: 6px; font-size: 14px; }
.input-group input {
    background: transparent; border: none;
    color: var(--text-main); width: 100%; height: 100%; font-size: 13px;
}
.menu-wrap { position: relative; }
.menu-trigger .ri-sparkling-line { color: #f5a623; }
.menu-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    min-width: 180px; padding: 6px 0;
    opacity: 0; visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transform-origin: top right;
    transition: opacity 0.25s, transform 0.25s cubic-bezier(0.34,1.56,0.64,1), visibility 0.25s;
    z-index: 999;
}
.menu-wrap.open .menu-dropdown {
    opacity: 1; visibility: visible;
    transform: translateY(0) scale(1);
}
.menu-divider { height: 1px; background: var(--border); margin: 4px 12px; }
.menu-hint { padding: 8px 16px 4px; font-size: 12px; color: var(--text-sub); }
.menu-sub-title { padding: 2px 16px 6px; font-size: 11px; color: var(--accent); font-weight: 600; }
.menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; color: var(--text-main);
    text-decoration: none; font-size: 13px; cursor: pointer;
    transition: background 0.15s, padding-left 0.2s;
}
.menu-item:hover { background: var(--bg-input); padding-left: 20px; }
.menu-item i { font-size: 16px; width: 20px; text-align: center; }
.menu-item .ri-heart-line { color: #ff6b6b; }
.menu-avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.donate-modal { max-width: 340px; }
.donate-body { text-align: center; }
.donate-body img {
    width: 100%; max-width: 280px;
    border-radius: var(--radius); margin-bottom: 12px;
}
.donate-hint { font-size: 13px; color: var(--text-sub); line-height: 1.5; }
.toast {
    position: fixed; bottom: 60px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-panel); color: var(--text-main);
    border: 1px solid var(--border);
    padding: 10px 24px; border-radius: 20px;
    font-size: 13px; box-shadow: var(--shadow);
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
    z-index: 10000; white-space: nowrap;
}
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.font-grid {
    flex: 1; padding: 16px; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    grid-auto-rows: min-content;
    gap: 16px; align-content: start; position: relative;
    transition: background 0.5s;
}
.font-card {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    display: flex; flex-direction: column; height: 160px;
    position: relative;
    transition: transform 0.2s, background 0.5s, border-color 0.3s;
}
.font-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.font-card:hover .card-export-btn { opacity: 1; }
.font-info {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; font-size: 11px; color: var(--text-sub);
    border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.font-name-tag {
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 80%; display: inline-block;
}
.font-preview {
    flex: 1; font-size: 28px; display: flex;
    align-items: center; justify-content: center;
    text-align: center; overflow: hidden;
    word-break: break-all; line-height: 1.2; padding: 0 8px;
}
.font-error { color: #ff4d4f; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.card-export-btn {
    position: absolute; bottom: 8px; right: 8px;
    background: var(--bg-input); color: var(--text-sub);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 3px 8px; font-size: 11px; cursor: pointer;
    opacity: 0; transition: opacity 0.2s, background 0.2s;
    display: flex; align-items: center; gap: 4px;
}
.card-export-btn:hover { background: var(--border); color: var(--text-main); }
.empty-state {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    text-align: center; color: var(--text-sub); grid-column: 1/-1;
}
.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; }
.browser-tip {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-panel); border-top: 1px solid var(--border);
    padding: 10px 16px; display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-sub); z-index: 50;
    animation: tipSlideUp 0.4s ease;
}
.browser-tip i { font-size: 16px; color: var(--accent); flex-shrink: 0; }
.browser-tip span { flex: 1; line-height: 1.4; }
.browser-tip-close {
    background: none; border: none; color: var(--text-sub);
    font-size: 16px; cursor: pointer; padding: 4px; flex-shrink: 0;
}
.browser-tip-close:hover { color: var(--text-main); }
.browser-tip.hidden { display: none; }
@keyframes tipSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.export-tip {
    display: flex; align-items: flex-start; gap: 8px;
    background: rgba(74,144,226,0.1); border: 1px solid rgba(74,144,226,0.25);
    border-radius: 6px; padding: 10px 12px; margin-bottom: 16px;
    font-size: 12px; color: var(--text-sub); line-height: 1.5;
}
.export-tip i { font-size: 15px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.export-tip b { color: var(--accent); font-weight: 600; }
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: none; justify-content: center; align-items: center; z-index: 100;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); width: 380px; max-height: 85vh;
    overflow-y: auto; padding: 24px; box-shadow: var(--shadow);
    color: var(--text-main);
    animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 20px;
}
.modal-header h3 {
    font-size: 16px; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}
.close-btn {
    background: none; border: none;
    color: var(--text-main); font-size: 20px; cursor: pointer;
}
.setting-item { margin-bottom: 16px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; }
.setting-col { display: flex; flex-direction: column; gap: 8px; }
.setting-row-inner { display: flex; justify-content: space-between; align-items: center; }
.setting-label { font-size: 14px; color: var(--text-main); }
.setting-input {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-main); padding: 10px 12px;
    border-radius: 6px; width: 100%; font-size: 14px;
}
.hint-text { font-size: 12px; color: var(--text-sub); margin-top: 4px; line-height: 1.5; }
.color-picker-wrap { display: flex; align-items: center; gap: 8px; }
.color-picker {
    width: 32px; height: 32px; border: 1px solid var(--border);
    border-radius: 6px; padding: 2px; cursor: pointer; background: var(--bg-input);
}
.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border: none; border-radius: 4px; }
.color-label { font-size: 12px; color: var(--text-sub); font-family: monospace; }
.range-slider {
    width: 100%; height: 4px;
    -webkit-appearance: none; appearance: none;
    background: var(--bg-input); border-radius: 4px;
}
.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: var(--accent); cursor: pointer;
}
.size-value { font-size: 12px; color: var(--accent); font-family: monospace; }
.toggle-switch {
    position: relative; display: inline-block;
    width: 44px; height: 24px; cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-input); transition: .3s; border-radius: 24px;
}
.slider:before {
    position: absolute; content: "";
    height: 18px; width: 18px; left: 3px; bottom: 3px;
    background: white; transition: .3s; border-radius: 50%;
}
input:checked + .slider { background: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); }
.result-stats { margin: 16px 0; }
.result-row {
    display: flex; justify-content: space-between;
    padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.result-row:last-child { border-bottom: none; }
.result-label { color: var(--text-sub); }
.result-value { font-weight: 600; }
.loader-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999; display: none; flex-direction: column;
    justify-content: center; align-items: center;
    color: #fff; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
}
.loader-overlay.active { display: flex; }
.spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid #fff;
    border-radius: 50%; animation: spin 1s linear infinite;
    margin-bottom: 16px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.progress-text { margin-top: 8px; font-size: 14px; opacity: 0.8; }

@media (max-width: 768px) {
    .toolbar {
        height: auto;
        padding: 46px 12px 10px 12px;
        flex-wrap: wrap; gap: 8px;
        position: relative;
    }
    .brand-section {
        position: absolute;
        top: 8px; left: 12px;
    }
    .brand { font-size: 15px; }
    .controls-section {
        display: flex; flex-wrap: wrap;
        width: 100%; gap: 8px;
    }
    .divider { display: none; }
    .btn-upload {
        flex: 1; justify-content: center;
        font-size: 12px; padding: 8px 10px;
    }
    .btn-action#screenshotBtn {
        flex: 1; justify-content: center;
        font-size: 12px; padding: 8px 10px;
    }
    .input-group { width: 100%; order: -1; }
    #findWrap {
        position: absolute;
        top: 8px; right: 100px;
    }
    #findWrap .menu-trigger {
        padding: 4px 8px; font-size: 11px; gap: 4px;
    }
    #menuWrap {
        position: absolute;
        top: 8px; right: 40px;
    }
    #menuWrap .menu-trigger {
        padding: 4px 8px; font-size: 11px; gap: 4px;
    }
    .menu-dropdown {
        right: 0; left: auto; min-width: 160px;
    }
    .theme-btn {
        position: absolute;
        top: 8px; right: 12px;
        padding: 4px 6px; font-size: 16px;
        border: none; background: transparent;
    }
    .font-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px; padding: 10px;
    }
    .font-card { height: 130px; padding: 10px; }
    .font-preview { font-size: 20px; }
    .font-info { font-size: 10px; margin-bottom: 8px; padding-bottom: 6px; }
    .card-export-btn { opacity: 1; font-size: 10px; padding: 2px 6px; }
    .modal-content { width: 92vw; max-height: 80vh; padding: 16px; }
    .donate-modal { max-width: 92vw; }
}
