:root {
    --bg-color: #f3f4f6;
    --toolbar-bg: #ffffff;
    --panel-bg: #ffffff;
    --border-color: #e5e7eb;
    --primary-color: #3b82f6;
    --text-color: #374151;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

html {
    margin: 0;
    padding: 0;
    height: 100%;
}

.canvas-site-container {
    margin-left: 240px;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.toolbar {
    height: 60px;
    background-color: var(--toolbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 15px;
    box-sizing: border-box;
}

.toolbar h1 {
    font-size: 18px;
    margin: 0;
    margin-right: 20px;
    font-weight: 600;
    color: #111827;
}

.toolbar button,
.toolbar input[type="file"] {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.toolbar button:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.toolbar .primary-btn {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.toolbar .primary-btn:hover {
    background: #2563eb;
}

.toolbar .divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 5px;
}

.main-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    background-color: #e5e5f7;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
}

.scale-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.canvas-container-outer {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background: white;
    transform-origin: center;
}

.property-panel {
    width: 280px;
    min-width: 280px;
    background-color: var(--panel-bg);
    border-left: 1px solid var(--border-color);
    padding: 20px;
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    box-sizing: border-box;
}

.property-panel.active {
    visibility: visible;
    opacity: 1;
}

.panel-section {
    margin-bottom: 20px;
}

.panel-section h3 {
    font-size: 14px;
    margin: 0 0 10px 0;
    color: #4b5563;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.prop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.prop-row label {
    font-size: 12px;
    color: #6b7280;
    width: 55px;
}

.prop-row input[type="number"],
.prop-row input[type="range"],
.prop-row select,
.prop-row input[type="color"] {
    flex: 1;
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
}

.prop-row input[type="checkbox"] {
    flex: none;
    width: auto;
}

.action-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.action-group button {
    flex: 1;
    min-width: 45%;
    padding: 6px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.action-group button:hover {
    background: #f3f4f6;
}

.btn-danger {
    color: #dc2626 !important;
    border-color: #f87171 !important;
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.zoom-controls button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    color: #374151;
}

.zoom-controls button:hover {
    background: #f3f4f6;
}

.zoom-controls span {
    margin: 0 10px;
    font-size: 13px;
    color: #374151;
    min-width: 45px;
    text-align: center;
    user-select: none;
}

.zoom-controls .reset-btn {
    font-size: 12px;
    width: auto;
    padding: 0 10px;
    margin-left: 5px;
    border-left: 1px solid var(--border-color);
    border-radius: 0;
}

/* 新增：弹窗系统与颜色选择器 CSS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    visibility: visible;
    opacity: 1;
}

.modal-box {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 360px;
    display: none;
}

.modal-box h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: #111827;
}

.modal-box hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.color-swatch,
.grad-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.color-swatch:hover,
.grad-swatch:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.fill-tabs {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 13px;
}

.fill-section {
    margin-bottom: 10px;
}

/* ★ Bug 3 修复：让原生 range 控件正常工作 */
.prop-row input[type="range"] {
    flex: 1;
    width: auto;
    min-width: 0;
    padding: 0;
    border: none;
    box-sizing: content-box;
    height: auto;
}

.canvas-title {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1;
}

.canvas-title h1 {
    margin: 0;
}

/* --- 替换掉原有的 .image-tools-links 及其 a 标签的样式 --- */

/* 新增的二级工具栏容器 */
.sub-toolbar {
    display: flex;
    align-items: center;
    padding: 6px 20px;
    background-color: #f9fafb; /* 浅灰色背景，与主工具栏区分 */
    border-bottom: 1px solid var(--border-color);
}

.sub-toolbar-label {
    font-size: 12px;
    color: #6b7280;
    margin-right: 12px;
}

.image-tools-links {
    display: flex;
    gap: 16px;
}

.image-tools-links a {
    font-size: 12px;
    color: #4b5563;
    text-decoration: none;
    transition: color 0.2s ease;
}

.image-tools-links a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}
