/* ===== 品牌设计变量 ===== */
:root {
  --brand: #2f6bff;
  --brand-dark: #1f56e0;
  --brand-light: #eef4ff;
  --text: #1c2433;
  --text-2: #5c6678;
  --text-3: #97a0b3;
  --border: #e6ebf4;
}

/* ===== Main Container（适配模板布局，填满 .main） ===== */
.main {
  padding: 18px 22px;
  height: 100%;
}
.main-container {
  display: flex;
  height: 100%;
  overflow: hidden;
  min-height: 0;
}

/* ===== Panels ===== */
.panel {
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px;
}
.panel-left {
  width: 220px;
}
.panel-right {
  width: 240px;
  border-right: none;
  border-left: 1px solid var(--border);
}

.panel-section {
  margin-bottom: 16px;
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.panel-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 32px;
  height: 2px;
  background: linear-gradient(135deg, #2f6bff, #1f56e0);
  border-radius: 2px;
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 8px;
}
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 3px;
}
.form-group input[type="number"],
.form-group select {
  width: 100%;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-group input[type="number"]:focus,
.form-group select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}
.form-group input[type="color"] {
  width: 100%;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  outline: none;
}

/* checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--brand);
}

/* HEX 颜色输入行 */
.color-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.color-input-row input[type="color"] {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 1px;
}
.color-input-row input[type="text"] {
  flex: 1;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.color-input-row input[type="text"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}
.form-group input[type="range"] {
  width: calc(100% - 40px);
  vertical-align: middle;
  margin-right: 4px;
  accent-color: var(--brand);
}
#textContent:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
  white-space: nowrap;
}
.btn:hover {
  background: var(--brand-light);
  border-color: #c9d8ff;
  color: var(--brand);
}
.btn-primary {
  background: linear-gradient(135deg, #2f6bff, #1f56e0);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(47, 107, 255, .25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1f56e0, #1a48c4);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(47, 107, 255, .32);
  transform: translateY(-1px);
}
.btn-danger {
  color: #e5484d;
  border-color: #f6c6c7;
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: #e5484d;
  color: #e5484d;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}
.btn-full {
  width: 100%;
  margin-top: 4px;
}
.btn-group {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.btn-group .btn {
  flex: 1;
}

/* ===== Canvas ===== */
.canvas-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #f3f5f9;
  overflow: hidden;
  position: relative;
}
.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.toolbar-label {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.toolbar-input {
  width: 68px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  text-align: center;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.toolbar-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}
.toolbar-sep {
  font-size: 12px;
  color: var(--text-3);
}
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.zoom-label {
  font-size: 12px;
  color: var(--text-3);
  min-width: 42px;
  text-align: center;
}
.canvas-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#mainCanvas {
  background: #fff;
  box-shadow: 0 8px 30px rgba(31, 66, 138, .08);
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* ===== Shape List ===== */
.shape-list {
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.shape-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all .15s;
}
.shape-item:hover {
  background: var(--brand-light);
  border-color: #c9d8ff;
}
.shape-item.active {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 500;
}
.shape-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-toggle-vis {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-toggle-vis:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}
.shape-item.hidden-shape {
  opacity: 0.5;
}
.shape-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
}
.shape-icon.circle {
  border-radius: 50%;
  border: 1.5px solid #555;
}
.shape-icon.rect {
  border-radius: 2px;
  border: 1.5px solid #555;
}

/* ===== Image ===== */
.img-crop-row {
  display: flex;
  gap: 6px;
}
.img-crop-row .form-group {
  flex: 1;
}
.shape-icon.text {
  width: 14px;
  height: 14px;
  display: inline-block;
  position: relative;
}
.shape-icon.text::after {
  content: 'T';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 700;
  color: #555;
  line-height: 1;
}

/* ===== Segment Selector ===== */
.segment-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.segment-tab {
  width: 30px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  transition: all .15s;
}
.segment-tab:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}
.segment-tab.active {
  background: linear-gradient(135deg, #2f6bff, #1f56e0);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(47, 107, 255, .28);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #2f6bff, #1f56e0);
  color: #fff;
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(47, 107, 255, .32);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.toast.show {
  opacity: 1;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .panel-left { width: 180px; }
  .panel-right { width: 200px; }
}
@media (max-width: 700px) {
  .main-container { flex-direction: column; }
  .panel-left, .panel-right { width: 100%; max-height: 200px; border: none; border-bottom: 1px solid var(--border); }
  .panel-right { border-bottom: none; border-top: 1px solid var(--border); }
  .canvas-wrapper { height: 50vh; }
}
