/* 主题编辑页 */
.theme-page-root {
    display: none;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: #f0f2f5;
}

.theme-page-root.active {
    display: flex;
}

.theme-page-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    flex-shrink: 0;
}

.theme-page-header .back-btn {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.theme-page-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #111;
    margin: 0;
}

.theme-page-header-spacer {
    position: absolute;
    right: 16px;
    width: 36px;
    height: 1px;
}

.theme-page-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 12px 100px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.theme-page-body::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.theme-section-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.theme-section-head {
    margin-bottom: 12px;
}

.theme-section-title {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #111;
}

.theme-section-hint {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    line-height: 1.4;
}

.theme-section-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.theme-thumb-wrap {
    width: 88px;
    height: 88px;
    border-radius: 10px;
    border: 1px dashed #ccc;
    background: #fafafa;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-thumb-wrap.has-image {
    border-style: solid;
    border-color: #e0e0e0;
}

.theme-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.theme-thumb-placeholder {
    font-size: 12px;
    color: #aaa;
    padding: 8px;
    text-align: center;
}

.theme-section-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.theme-btn {
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
}

.theme-btn-secondary {
    background: #07c160;
    color: #fff;
}

.theme-btn-secondary:active {
    opacity: 0.9;
}

.theme-btn-ghost {
    background: #f5f5f5;
    color: #555;
}

.theme-icons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    /* 默认展示两排（4 个/排），超出部分在框内纵向滚动查看；滚动条对用户隐形但可正常触摸/滚轮滚动 */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.theme-icons-grid::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.theme-icons-grid.theme-icons-grid--scrollable {
    /* 轻量渐隐提示：底部还有更多图标可滑动查看；滑到底部后自动取消渐隐 */
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent 100%);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 14px), transparent 100%);
}

.theme-icons-grid.theme-icons-grid--scrollable.theme-icons-grid--at-bottom {
    -webkit-mask-image: none;
    mask-image: none;
}

.theme-icon-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.theme-icon-preview {
    width: 100%;
    aspect-ratio: 1;
    max-width: 64px;
    padding: 0;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    background: #fafafa;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-icon-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    -webkit-object-fit: contain;
    object-position: center;
}

/* 自定义预览与桌面一致：贴合预览框（cover） */
.theme-icon-preview.theme-icon-wrap--custom img,
.theme-icon-preview img.theme-icon-img--custom {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-radius: inherit;
    object-fit: cover;
    -webkit-object-fit: cover;
    object-position: center;
}

.theme-icon-label {
    font-size: 11px;
    color: #444;
}

.theme-mini-link {
    border: none;
    background: none;
    color: #576b95;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 0;
}

.theme-font-preview-block {
    border: 1px solid #e8edf2;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbfcfe 0%, #f4f7fa 100%);
    padding: 14px;
}

.theme-font-sample {
    color: #33404d;
    line-height: 1.65;
    font-size: 20px;
    word-break: break-word;
}

.theme-font-sample-title {
    font-size: 0.9em;
    font-weight: 600;
    margin-bottom: 8px;
}

.theme-font-sample-line + .theme-font-sample-line {
    margin-top: 6px;
}

.theme-font-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.theme-text-input {
    width: 100%;
    border: 1px solid #dbe3ea;
    border-radius: 10px;
    background: #fff;
    padding: 11px 12px;
    font-size: 13px;
    color: #2f3b47;
    outline: none;
    box-sizing: border-box;
}

.theme-text-input:focus {
    border-color: #8ea4b8;
    box-shadow: 0 0 0 3px rgba(142, 164, 184, 0.14);
}

.theme-font-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.theme-font-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-font-slider-label {
    flex-shrink: 0;
    font-size: 13px;
    color: #4a5968;
}

.theme-font-size-range {
    flex: 1;
    accent-color: #7f97ab;
}

.theme-font-size-value {
    min-width: 42px;
    text-align: right;
    font-size: 12px;
    color: #708395;
}

.theme-scheme-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.theme-btn-scheme-pick {
    background: #eef7f1;
    color: #0a8f4d;
}

.theme-btn-scheme-pick:active {
    opacity: 0.9;
}

.theme-scheme-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.45);
}

.theme-scheme-modal.active {
    display: flex;
}

.theme-scheme-dialog {
    width: 100%;
    max-width: 320px;
    max-height: 78vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    box-sizing: border-box;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.theme-scheme-dialog-title {
    font-size: 16px;
    font-weight: 600;
    color: #111;
    margin-bottom: 10px;
}

.theme-scheme-dialog-desc {
    font-size: 12px;
    color: #6b7a88;
    line-height: 1.5;
    margin-bottom: 10px;
    word-break: break-word;
}

.theme-scheme-dialog-count {
    font-size: 12px;
    color: #8b98a5;
    line-height: 1.5;
    margin-top: 8px;
}

.theme-scheme-dialog-btns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.theme-scheme-dialog-btns--single {
    grid-template-columns: 1fr;
}

.theme-scheme-pick-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.theme-scheme-list {
    flex: 1;
    min-height: 0;
    max-height: 52vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
}

.theme-scheme-empty {
    border: 1px dashed #d7dfe6;
    border-radius: 10px;
    background: #f7f9fb;
    padding: 16px 12px;
    font-size: 12px;
    color: #8b98a5;
    line-height: 1.6;
    text-align: center;
}

.theme-scheme-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #e8edf2;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    background: #fafbfc;
}

.theme-scheme-item:active {
    background: #f0f4f7;
}

.theme-scheme-item.is-active {
    border-color: #07c160;
    background: #f2fbf6;
}

.theme-scheme-item-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #eef1f4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #9aa7b3;
}

.theme-scheme-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.theme-scheme-item-main {
    flex: 1;
    min-width: 0;
}

.theme-scheme-item-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.theme-scheme-item-name-text {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.theme-scheme-item-badge {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 400;
    color: #07c160;
    border: 1px solid rgba(7, 193, 96, 0.4);
    border-radius: 6px;
    padding: 1px 5px;
}

.theme-scheme-item-meta {
    font-size: 11px;
    color: #8b98a5;
    margin-top: 3px;
    line-height: 1.4;
    word-break: break-word;
}

.theme-scheme-item-delete {
    flex-shrink: 0;
    border: none;
    background: #fdf0f0;
    color: #d05050;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
}

.theme-scheme-item-delete:active {
    opacity: 0.85;
}

.theme-reset-btn {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    font-size: 15px;
}

.theme-reset-btn:disabled {
    background: #f0f0f0;
    color: #b0b0b0;
    cursor: not-allowed;
}

.theme-reset-btn:disabled:active {
    transform: none;
    filter: none;
}

.theme-page-footer {
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    padding-bottom: max(12px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.theme-footer-btn {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-size: 15px;
    cursor: pointer;
}

.theme-footer-cancel {
    background: #f0f0f0;
    color: #333;
}

.theme-footer-save {
    background: #07c160;
    color: #fff;
}
