:root {
    --primary: #6d5dfc;
    --primary-dark: #5143db;
    --ink: #172033;
    --muted: #667085;
    --line: #e4e7ec;
    --panel: rgba(255, 255, 255, 0.96);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { width: 100%; max-width: 100%; min-height: 100%; overflow-x: hidden; }

body {
    margin: 0;
    color: var(--ink);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

.diamond-page > main.container {
    width: 100%;
    max-width: 100%;
    padding-right: 12px;
    padding-left: 12px;
}

.tool-content {
    padding: 30px;
    background: rgba(255, 255, 255, .98);
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .1);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px;
    color: #6366f1;
    font-size: 1.75rem;
    font-weight: 750;
}

.step-indicator {
    height: 100%;
    padding: 15px 18px;
    color: #1e40af;
    background: linear-gradient(135deg, #dbeafe, #e0e7ff);
    border-left: 4px solid #6366f1;
    border-radius: 10px;
    font-weight: 650;
}

.tool-card { overflow: hidden; border: 1px solid #e2e8f0; border-radius: 14px; }
.tool-card-header { padding: 13px 16px; color: white; background: linear-gradient(135deg, #6366f1, #8b5cf6); border: 0; font-weight: 700; }
.source-preview { display: grid; place-items: center; min-height: 360px; overflow: hidden; color: #94a3b8; background: linear-gradient(135deg, #f8fafc, #e2e8f0); cursor: pointer; }
.source-preview > div { display: grid; place-items: center; gap: 8px; font-size: 1rem; }
.source-preview > div i { font-size: 2rem; }
.source-preview img { display: block; width: 100%; max-height: 520px; object-fit: contain; }
.info-badge { margin: 0 0 24px; padding: 15px 20px; color: #92400e; background: linear-gradient(135deg, #fef3c7, #fde68a); border-left: 4px solid #f59e0b; border-radius: 10px; }
.btn-primary-tool { width: 100%; min-height: 44px; padding: 10px 14px; color: white; background: linear-gradient(135deg, #6366f1, #8b5cf6); border: 0; border-radius: 11px; font-weight: 700; }
.generate-row { margin: 0 0 24px; text-align: center; }
.generate-row .btn-generate { width: auto; min-width: 240px; margin-top: 0; }

.tool-header, .settings-panel, .preview-panel {
    background: rgba(255, 255, 255, .97);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 16px 45px rgba(66, 56, 157, 0.1);
}

.tool-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 28px;
    border-radius: 20px;
    margin-bottom: 20px;
}

.back-link { color: var(--primary-dark); text-decoration: none; font-weight: 600; }
.tool-header h1 { margin: 12px 0 6px; font-size: clamp(1.65rem, 4vw, 2.35rem); font-weight: 800; }
.tool-header h1 i { color: var(--primary); }
.tool-header p { margin: 0; color: var(--muted); }

.size-summary { min-width: 210px; padding: 14px 18px; border-radius: 16px; background: #f1efff; }
.size-summary span, .size-summary small { display: block; color: var(--muted); }
.size-summary strong { display: block; margin: 3px 0; color: var(--primary-dark); font-size: 1.2rem; }

.workspace { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 20px; }
.settings-panel, .preview-panel { border-radius: 22px; padding: 24px; min-width: 0; }
.settings-panel h2 { margin: 0 0 14px; font-size: 1.05rem; font-weight: 750; }
.settings-panel h2:not(:first-child) { margin-top: 28px; }
.settings-panel h2 span { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 7px; color: white; background: var(--primary); border-radius: 50%; font-size: .82rem; }
.form-label { color: #344054; font-weight: 650; }
.form-control { min-height: 44px; border-color: #d0d5dd; border-radius: 11px; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109, 93, 252, .14); }
.field-help { display: block; margin-top: 5px; color: var(--muted); font-size: .8rem; }

.file-drop { display: grid; gap: 5px; place-items: center; padding: 20px 12px; border: 2px dashed #c7c1ff; border-radius: 14px; background: #faf9ff; cursor: pointer; text-align: center; }
.file-drop:hover { border-color: var(--primary); background: #f5f3ff; }
.file-drop i { color: var(--primary); font-size: 1.45rem; }
.file-drop small { color: var(--muted); }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.palette-status { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; color: var(--muted); font-size: .88rem; }
.palette-status strong { color: var(--primary-dark); white-space: nowrap; }
.btn-import-palette { width: 100%; margin-top: 10px; padding: 11px 14px; color: white; background: linear-gradient(135deg, #6366f1, #8b5cf6); border: 0; border-radius: 10px; font-weight: 700; }
.btn-import-palette:hover { box-shadow: 0 8px 18px rgba(99, 102, 241, .24); transform: translateY(-1px); }
/* 7-255 账号命名色库：已存色库下拉 + 删除所选 */
.palette-saved-row { display: flex; gap: 8px; margin-top: 10px; }
.palette-saved-row select { flex: 1; min-width: 0; padding: 8px 9px; color: var(--primary-dark); background: white; border: 1px solid #c7c1ff; border-radius: 9px; font-size: .83rem; font-weight: 650; }
.palette-saved-row button { flex: 0 0 auto; padding: 8px 12px; color: #b91c1c; background: white; border: 1px solid #fecaca; border-radius: 9px; font-size: .83rem; font-weight: 650; }
.palette-saved-row button:disabled { color: #94a3b8; border-color: #e2e8f0; }
.palette-help-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.palette-help-actions button:last-child { grid-column: 1 / -1; }
.palette-help-actions button { flex: 1; padding: 8px 9px; color: var(--primary-dark); background: white; border: 1px solid #c7c1ff; border-radius: 9px; font-size: .83rem; font-weight: 650; }
.palette-help { margin-top: 10px; padding: 12px; color: #475467; background: #f8f7ff; border: 1px solid #dedaff; border-radius: 11px; font-size: .82rem; }
.palette-help pre { margin: 8px 0; padding: 9px; overflow-x: auto; color: #344054; background: white; border: 1px solid var(--line); border-radius: 7px; }
.palette-help ul { margin: 0; padding-left: 18px; }
.palette-help li + li { margin-top: 4px; }
.free-limit-note { display: flex; gap: 9px; align-items: flex-start; margin-top: 12px; padding: 10px 11px; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; font-size: .86rem; }
.free-limit-note i { margin-top: 2px; color: #f59e0b; }
.licence-box { margin-top: 12px; padding: 13px; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; }
.licence-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.licence-heading h3 { margin: 0; color: #344054; font-size: .95rem; font-weight: 750; }
.licence-state { padding: 3px 8px; color: #667085; background: #eaecf0; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.licence-state.valid { color: #027a48; background: #d1fadf; }
.btn-verify { width: 100%; padding: 9px 12px; color: var(--primary-dark); background: white; border: 1px solid #c7c1ff; border-radius: 9px; font-weight: 700; }
.licence-message { min-height: 18px; margin: 8px 0 0; color: #667085; font-size: .8rem; }

.btn-generate { width: 100%; margin-top: 24px; padding: 13px 18px; color: white; background: linear-gradient(135deg, var(--primary), #8b5cf6); border: 0; border-radius: 13px; font-weight: 750; box-shadow: 0 10px 22px rgba(109, 93, 252, .25); }
.btn-generate:disabled { opacity: .45; box-shadow: none; }
.message { min-height: 24px; margin: 10px 0 0; color: #b42318; font-size: .9rem; }

.preview-toolbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px; }
.preview-toolbar h2 { margin: 0 0 3px; font-size: 1.25rem; font-weight: 750; }
.preview-toolbar p { margin: 0; color: var(--muted); }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.toolbar-actions button { padding: 9px 12px; color: var(--primary-dark); background: white; border: 1px solid #c7c1ff; border-radius: 10px; font-weight: 650; }
.toolbar-actions button:disabled { color: #98a2b3; border-color: var(--line); }

.canvas-stage { display: grid; place-items: center; min-height: 520px; max-height: 70vh; padding: 18px; overflow: auto; border: 1px solid var(--line); border-radius: 16px; background-color: #eef0f5; background-image: linear-gradient(45deg, #e3e5eb 25%, transparent 25%), linear-gradient(-45deg, #e3e5eb 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e3e5eb 75%), linear-gradient(-45deg, transparent 75%, #e3e5eb 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.empty-preview { display: grid; place-items: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-preview i { color: #aaa2ff; font-size: 3rem; }
.empty-preview strong { color: #475467; font-size: 1.1rem; }
.preview-title { margin: 0 0 10px; color: #475467; font-size: 1rem; font-weight: 750; }
#previewCanvas, #productCanvas { max-width: 100%; height: auto; background: white; box-shadow: 0 8px 25px rgba(16, 24, 40, .18); }
.usage-panel { margin-top: 18px; }
.usage-panel h3 { font-size: 1rem; font-weight: 750; }
.usage-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 8px; }
.usage-item { display: flex; align-items: center; gap: 8px; padding: 8px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; }
.swatch { flex: 0 0 24px; width: 24px; height: 24px; border: 1px solid rgba(0,0,0,.15); border-radius: 7px; }
.usage-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.usage-item strong { margin-left: auto; }

@media (max-width: 991.98px) {
    .workspace { grid-template-columns: 1fr; }
    .canvas-stage { min-height: 420px; max-height: none; }
}

@media (max-width: 575.98px) {
    .diamond-page > main.container {
        padding-right: 10px;
        padding-left: 10px;
    }
    .tool-content { padding: 14px 10px; border-radius: 14px; }
    .section-title { font-size: 1.4rem; }
    .step-indicator { padding: 12px 10px; font-size: .86rem; }
    .source-preview { min-height: 72vw; }
    .generate-row .btn-generate { width: 100%; min-width: 0; }
    .tool-header { align-items: stretch; flex-direction: column; padding: 18px; border-radius: 16px; }
    .size-summary { min-width: 0; }
    .settings-panel, .preview-panel { padding: 16px; border-radius: 16px; }
    .preview-toolbar { align-items: stretch; flex-direction: column; }
    .toolbar-actions { justify-content: stretch; }
    .toolbar-actions button { flex: 1 1 100%; }
    .palette-help-actions { grid-template-columns: 1fr; }
    .palette-help-actions button:last-child { grid-column: auto; }
    .canvas-stage { min-height: 300px; padding: 8px; }
}
