/* ========== 基础与重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif; }

.diy-container { width: 100%; height: 100vh; display: flex; flex-direction: column; background: #fff; }

/* 1. 恢复的顶部导航栏 */
.diy-navbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #fff; flex-shrink: 0; }
.back-btn { width: 36px; height: 36px; background: #f5f5f5; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.navbar-title { font-size: 16px; font-weight: 600; color: #333; }
.navbar-finish-btn { background: #222; color: #fff; border: none; padding: 8px 18px; border-radius: 20px; font-size: 13px; font-weight: 500; cursor: pointer; transition: transform 0.2s; }
.navbar-finish-btn:active { transform: scale(0.95); }
.navbar-action-spacer { width: 36px; height: 36px; flex-shrink: 0; }

/* 2. 状态与信息栏 */
.diy-top-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px 12px; background: #fff; z-index: 10; flex-shrink: 0; }
.usage-btn { display: flex; align-items: center; gap: 4px; background: #e74c3c; color: #fff; border: none; padding: 6px 12px; border-radius: 16px; font-size: 12px; font-weight: 500; cursor: pointer; }
.top-info-right { display: flex; gap: 8px; }
.info-pill { background: #f5f5f5; color: #666; font-size: 12px; padding: 6px 12px; border-radius: 16px; font-weight: 500; border: 1px solid #eee; }
.info-pill span { color: #333; font-weight: 600; font-size: 13px; }

/* 3. 沉浸式手链画布区 */
.diy-canvas-area {
    flex: 1; /* 自动占据剩余空间 */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff; /* 去掉灰色渐变，保持干净的白色画布 */
    overflow: hidden;
    touch-action: none;
}
.zoom-wrapper { transform-origin: center center; will-change: transform; }
.bracelet { width: 220px; height: 220px; position: relative; display: flex; align-items: center; justify-content: center; touch-action: none; }
.bracelet-ring { position: absolute; width: 100%; height: 100%; border-radius: 50%; border: 3px solid #e5e5e5; pointer-events: none; }
.brand-watermark { text-align: center; color: #ccc; display: flex; flex-direction: column; line-height: 1.2; user-select: none; }
.brand-watermark strong { font-size: 14px; letter-spacing: 1px; }
.brand-watermark span { font-size: 11px; }

/* 画布上的珠子 */
.bracelet-bead { position: absolute; top: 50%; left: 50%; width: 45px; height: 45px; margin: -22.5px 0 0 -22.5px; border-radius: 50%; background-color: transparent; background-size: cover; background-position: center; cursor: grab; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18)); touch-action: none; will-change: transform; }
.bracelet-bead:active { cursor: grabbing; }
.bracelet-bead.dragging { filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.28)); z-index: 999; }

/* 4. 中部操作栏 */
.diy-action-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px 10px; background: #fff; border-top: 1px solid #f0f0f0; flex-shrink: 0; }
.action-icon-btn { width: 36px; height: 34px; background: #fff; border: 1.5px solid #2f2a34; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #2f2a34; cursor: pointer; transition: background 0.2s ease, transform 0.2s ease; flex-shrink: 0; }
.action-icon-btn:active { background: #f6f3ef; transform: scale(0.98); }

.action-right-btns { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.btn-save,
.btn-primary-action { height: 34px; border-radius: 11px; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease; white-space: nowrap; }
.btn-save svg,
.btn-primary-action svg { flex-shrink: 0; }
.btn-save { background: #ef4b3f; border: 1px solid #ef4b3f; color: #fff; padding: 0 14px; min-width: 78px; box-shadow: 0 8px 18px rgba(239, 75, 63, 0.18); }
.btn-save:active { background: #df4034; border-color: #df4034; transform: scale(0.98); }
.btn-primary-action { margin-left: auto; background: #fff; border: 1.5px solid #3b3542; color: #3b3542; padding: 0 14px; min-width: 112px; }
.btn-primary-action:active { background: #f6f3ef; transform: scale(0.98); }
.btn-primary-action.is-pick-mode { min-width: 104px; }
.btn-save:disabled,
.btn-primary-action:disabled,
.action-icon-btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none; }

/* 5. 底部选择区 (黄金比例高度限制) */
.diy-selector-area {
    height: 42vh; /* 严格限制高度，约占屏幕的五分之二 */
    min-height: 280px; /* 极端小屏兜底高度 */
    display: flex;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

/* 5.1 左侧分类栏 */
.sidebar-categories { width: 80px; background: #f8f8f8; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sidebar-categories::-webkit-scrollbar { display: none; }
.category-item { padding: 16px 8px; text-align: center; font-size: 13px; color: #666; cursor: pointer; position: relative; transition: all 0.2s; }
.category-item.active { background: #fff; color: #333; font-weight: 600; }
.category-item.active::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; background: #333; border-radius: 0 2px 2px 0; }

/* 5.2 右侧主内容区 */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* 搜索栏 */
.search-header { display: flex; align-items: center; gap: 10px; padding: 12px 12px 8px; background: #fff; }
.undo-icon-btn { width: 32px; height: 32px; background: #f5f5f5; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #333; cursor: pointer; flex-shrink: 0; }
.search-input-box { flex: 1; position: relative; display: flex; align-items: center; }
.search-input-box svg { position: absolute; left: 12px; pointer-events: none; }
.search-input-box input { width: 100%; height: 34px; padding: 0 12px 0 34px; border: 1px solid #eee; border-radius: 17px; font-size: 12px; background: #f9f9f9; outline: none; }
.search-input-box input:focus { border-color: #ccc; }

/* 珠子网格 */
.bead-grid { flex: 1; overflow-y: auto; padding: 8px 12px 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-content: start; -webkit-overflow-scrolling: touch; }
.bead-card { border: 1px solid #f0f0f0; border-radius: 12px; padding: 12px 4px; display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: background 0.2s; background: #fff; }
.bead-card:active { background: #fafafa; border-color: #e0e0e0; }
.bead-img-box { width: 44px; height: 44px; border-radius: 50%; margin-bottom: 8px; overflow: hidden; }
.bead-img-box img { width: 100%; height: 100%; object-fit: cover; }
.bead-name { font-size: 12px; color: #333; font-weight: 500; margin-bottom: 4px; text-align: center; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.bead-spec { font-size: 11px; color: #888; font-weight: 500; text-align: center; }

.loading-text { grid-column: 1 / -1; text-align: center; font-size: 13px; color: #999; padding: 20px 0; width: 100%; }
.toast { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, 0.8); color: #fff; padding: 12px 24px; border-radius: 8px; font-size: 14px; z-index: 9999; opacity: 0; visibility: hidden; transition: opacity 0.3s; }
.toast.show { opacity: 1; visibility: visible; }

.diy-modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(17, 17, 17, 0.24); z-index: 10000; }
.diy-modal[hidden] { display: none; }
.diy-modal-dialog { width: min(320px, 100%); background: #fff; border-radius: 20px; padding: 22px 18px 16px; box-shadow: 0 20px 40px rgba(17, 17, 17, 0.16); text-align: center; }
.diy-modal-dialog h3 { font-size: 18px; font-weight: 700; color: #222; margin-bottom: 10px; }
.diy-modal-dialog p { font-size: 13px; line-height: 1.65; color: #6b6670; }
.diy-modal-actions { margin-top: 18px; display: flex; gap: 10px; }
.btn-modal-secondary,
.btn-modal-danger { flex: 1; height: 40px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-modal-secondary { background: #f6f3ef; border: 1px solid #ece5dd; color: #4b4550; }
.btn-modal-danger { background: #ef4b3f; border: 1px solid #ef4b3f; color: #fff; }

.diy-selector-area {
    height: 34vh;
    min-height: 220px;
    max-height: 300px;
}
