* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  padding: 20px;
  background: #f5f5f5;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}
.header {
  max-width: 1200px;
  margin: 0 auto 20px auto;
  padding: 20px 20px;
  background: #fff;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
}
.header-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 2px;
  position: relative;
}
.header-title .chai {
  background: linear-gradient(120deg, #B2714B 0%, #D07E4A 100%);
  -webkit-background-clip: text;
  color: transparent;
}
.header-title .dou {
  color: #333;
  font-weight: 800;
}
.header-title::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 3px;
  background: #B2714B;
  border-radius: 3px;
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  background: #fff;
  padding: 20px;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.upload {
  border: 2px dashed #ccc;
  padding: 30px;
  text-align: center;
  margin: 20px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}
.upload.drag {
  border-color: #4285F4;
  background: #E8F9FF;
}
#preview {
  max-height: 200px;
  display: block;
  margin: 10px auto;
  display: none;
}
.panel {
  margin: 10px 0;
}
.panel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 8px 0;
  line-height: 2.4;
}
.panel input {
  width: 60px;
  padding: 6px;
  text-align: center;
  margin: 0 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
}
.panel input.warn {
  border: 1px solid #ff4444;
  background: #fff8f8;
}
.warn-text {
  color: #ff4444;
  font-size: 12px;
  margin-left: 8px;
  display: none;
}
button {
  padding: 8px 16px;
  background: #4285F4;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  margin: 0 5px;
  transition: all 0.2s;
}
button:hover {
  background: #3367D6;
}
button:disabled {
  background: #ccc;
  cursor: not-allowed;
}
#exportImg {
  background: #34A853;
}
#exportImg:hover {
  background: #2D8496;
}
/* 新增：生成图纸按钮样式（补充缺失的#gen） */
#gen {
  background: #4285F4; /* 与button基础样式一致，保持默认蓝色 */
}
#gen:hover {
  background: #3367D6; /*  hover态加深，与基础样式hover逻辑一致 */
}

/* 新增：生成空白图纸按钮样式 */
#genBlank {
  background: #28a745; /* 绿色系，区分生成图纸按钮 */
}
#genBlank:hover {
  background: #218838; /* hover态加深，保持交互一致性 */
}
#editGrid {
  background: #FF9900;
}
#editGrid:hover {
  background: #FF8800;
}
#saveEdit {
  background: #28a745;
  display: none;
}
#cancelEdit {
  background: #6c757d;
  display: none;
}
#flipGrid {
  background: #9C27B0;
}
#flipGrid:hover {
  background: #7B1FA2;
}
#beanMode {
  background: #1E90FF;
}
#beanMode:hover {
  background: #1976D2;
}
#exitBeanMode {
  background: #FF6347;
  display: none;
}
#exitBeanMode:hover {
  background: #E53935;
}
.switch-item {
  margin: 0 10px;
}
.edit-mode {
  border: 2px solid #FF9900;
  box-shadow: 0 0 10px rgba(255, 153, 0, 0.3);
}
.color-selector {
  max-width: 1000px;
  margin: 15px auto;
  padding: 15px;
  background: #f5f5f5;
  border-radius: 8px;
  display: none;
}
.color-selector h4 {
  margin-bottom: 10px;
  color: #333;
  font-size: 16px;
}
.color-option {
  display: inline-block;
  width: 50px;
  height: 50px;
  margin: 5px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  text-align: center;
  vertical-align: top;
}
.color-option.selected {
  border-color: #FF9900;
  box-shadow: 0 0 5px #FF9900;
}
.color-preview {
  width: 36px;
  height: 36px;
  margin: 0 auto;
}
.color-code {
  font-size: 12px;
  margin-top: 2px;
  color: #333;
}
.cell.editable {
  cursor: pointer;
}
.cell.editable:hover {
  transform: scale(1.02);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
.cell.empty {
  background: #fff !important;
}
.cell.empty span {
  color: transparent !important;
}
.cell {
  transition: opacity 0.3s;
}
.bean-mode-panel {
  max-width: 1000px;
  margin: 15px auto;
  padding: 15px;
  background: #f5f5f5;
  border-radius: 8px;
  display: none;
  border: 2px solid #1E90FF;
}
.bean-mode-panel h4 {
  margin-bottom: 10px;
  color: #333;
  font-size: 16px;
}
.bean-color-item {
  display: inline-block;
  width: 60px;
  height: 60px;
  margin: 8px;
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 6px;
  text-align: center;
  vertical-align: top;
  transition: all 0.2s;
}
.bean-color-item.active {
  border-color: #FF6347;
  box-shadow: 0 0 8px rgba(255, 99, 71, 0.5);
  transform: scale(1.05);
}
.bean-color-preview {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border-radius: 4px;
}
.bean-color-code {
  font-size: 14px;
  margin-top: 4px;
  color: #333;
  font-weight: 600;
}
#deleteColor {
  background: #F44336;
  padding: 6px 12px;
  font-size: 14px;
  margin: 5px 0 10px 0;
}
#deleteColor:hover {
  background: #D32F2F;
}
#deleteBlockColor {
  background: #FF5722;
  padding: 6px 12px;
  font-size: 14px;
  margin: 5px 0 10px 5px;
}
#deleteBlockColor:hover {
  background: #E64A19;
}
#changeBlockColor {
  background: #FF9800;
  padding: 6px 12px;
  font-size: 14px;
  margin: 5px 0 10px 5px;
}
#changeBlockColor:hover {
  background: #FB8C00;
}
#openAllColors {
  background: #17a2b8;
  padding: 6px 12px;
  font-size: 14px;
  margin: 5px 0 10px 0;
}
#openAllColors:hover {
  background: #138496;
}
#allColorsPanel {
  background: #fff;
  padding: 10px;
  border-radius: 6px;
  margin-top: 10px;
  display: none;
}
.color-group {
  display: inline-block;
  vertical-align: top;
  margin: 0 10px 10px 0;
}
.group-title {
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 14px;
}
.group-colors {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}
.all-color-item {
  width: 34px;
  height: 34px;
  cursor: pointer;
  border: 1px solid #ddd;
  font-size: 9px;
  font-weight: bold;
  text-align: center;
  line-height: 34px;
}
#grid {
  display: grid;
  width: 100%;
  max-width: 1000px;
  margin: 20px auto;
  border: 1px solid #ddd;
  background: #fff;
}
.cell {
  /* 保留原有其他样式，仅替换宽高相关配置 */
  width: 100% !important;
  height: auto !important; /* 取消高度0的设置 */
  padding: 0 !important; /* 取消padding-bottom占比 */
  position: relative;
  border: 1px solid #eee;
  box-sizing: border-box;
  /* 核心修复：强制宽高比1:1，不受布局影响 */
  aspect-ratio: 1/1 !important;
}
.cell span {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.cell.hide-text span {
  color: transparent !important;
}
.grid-line {
  border-left: 2px solid #000 !important;
  border-top: 2px solid #000 !important;
}
.grid-line .cell.col-10x {
  border-right: 2px solid #000 !important;
}
.grid-line .cell.row-10x {
  border-bottom: 2px solid #000 !important;
}
.color-stat {
  max-width: 1000px;
  margin: 20px auto;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
  display: none;
  border: 1px solid #eee;
}
.color-stat h4 {
  margin-bottom: 10px;
  color: #333;
  font-size: 16px;
}
.stat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 4px;
  font-size: 12px;
}
.stat-color {
  width: 16px;
  height: 16px;
  border-radius: 2px;
}
#exportCanvas {
  position: absolute;
  top: -9999px;
  left: -9999px;
  background: #ffffff;
  display: none;
}
/* 锁定按钮样式 */
#lockBtn {
  position: fixed;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #FF6347;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  z-index: 10000;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  transition: all 0.2s;
  display: none;
  align-items: center;
  justify-content: center;
}
#lockBtn:hover {
  background: #E53935;
  transform: translateY(-50%) scale(1.1);
}

/* 解锁按钮样式（含长按动画） */
#unlockBtn {
  position: fixed;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #28a745;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  z-index: 10000;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  transition: all 0.2s;
  display: none;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
#unlockBtn:hover {
  background: #218838;
  transform: translateY(-50%) scale(1.1);
}
/* 按钮文字层级 */
#lockBtn span, #unlockBtn span {
  position: relative;
  z-index: 2;
}


/* 全透明蒙层（增强防滑动） */
#lockMask {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh; /* 用vh确保覆盖视口，避免滚动 */
  background: rgba(0,0,0,0.01) !important;
  z-index: 9999;
  pointer-events: auto;
  backdrop-filter: none !important;
  /* 新增：阻止触摸滑动（移动端兼容） */
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}
#lockMask.active {
  display: block !important;
}
/* 分享链接弹窗按钮样式 */
#shareLink {
  background: #1E90FF;
}
#shareLink:hover {
  background: #1976D2;
}
#shareLinkModal input {
  font-size: 14px;
}
#copyShareUrl:hover {
  background: #218838;
}
#closeShareModal:hover {
  background: #5a6268;
}
#historyGrid {
  background: #6f42c1;
}
#historyGrid:hover {
  background: #5a32a3;
}
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid #eee;
  border-radius: 6px;
}
.history-name {
  flex: 1;
  padding: 0 10px;
  font-size: 14px;
}
.history-item button {
  padding: 6px 10px;
  font-size: 12px;
  margin-left: 6px;
}

