:root {
  --primary: #3498db;
  --primary-dark: #2980b9;
  --border: #e0e0e0;
  --gray: #95a5a6;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #f0f7ff, #e3f2fd);
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 20px;
}

header h1 {
  font-size: 2.2rem;
  color: var(--primary);
  margin-bottom: 8px;
}

header p {
  color: var(--gray);
  font-size: 1rem;
}

.main-layout {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

/* ===== 左侧：带圆角，但内部操作区直角 ===== */
.canvas-area {
    flex: 2;
    min-width: 680px;
    height: 730px; /* ← 新增固定高度 */
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    display: flex;
flex-direction: column;
}

.tool-area {
    flex: 0 0 320px; /* ← 改为固定宽度 280px */
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px; /* ← 略微缩小内边距 */
    height: 730px;
}

.panel {
  margin-bottom: 28px;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--primary);
}

.upload-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 18px;
  text-align: center;
  transition: background 0.2s;
}

.upload-btn:hover {
  background: var(--primary-dark);
}

#fileInput {
  display: none;
}

#imageContainer {
    flex: 1;
    /* ✅ 新增：棋盘格背景（纯 CSS，高性能） */
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #cccccc 25%, transparent 25%),
        linear-gradient(-45deg, #cccccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #cccccc 75%),
        linear-gradient(-45deg, transparent 75%, #cccccc 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    overflow: hidden;
    position: relative;
    border-radius: 8px 8px 0 0;
}

#image {
  display: none;
  max-width: none;
  max-height: none;
}

/* 工具区样式 */
.form-group {
  margin-bottom: 14px;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 5px;
  color: #444;
}

select, input[type="range"], input[type="number"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
}

.quality-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.quality-value {
  width: 46px;
  text-align: center;
  font-weight: 600;
  color: var(--primary);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 0.92rem;
}

.info-label {
  font-weight: 600;
  color: #555;
}

.info-value {
  color: #222;
}

.btn {
  display: inline-block;
  padding: 9px;
  background: #f0f0f0;
  color: #333;
  border: none;
  border-radius: 4px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  flex: 1;
  width: 100%;
}

.btn:hover {
  background: #e0e0e0;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-group {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}

.size-preview {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--primary);
  margin-top: 10px;
  padding: 10px;
  background: #eef7ff;
  border-radius: 4px;
  text-align: center;
}

/* ===== Cropper.js 样式增强 ===== */
/* 放大裁剪框控制点 */
.cropper-point {
  width: 12px !important;
  height: 12px !important;
  background-color: var(--primary) !important;
  border: 2px solid var(--primary) !important;
  opacity: 1 !important;
}
/* 放大边线中点 */
.cropper-line {
  background-color: var(--primary) !important;
}
.cropper-dashed {
  border: 1px dashed rgba(255, 255, 255, 0.6) !important;
}
/* 裁剪框本身 */
.cropper-view-box {
  outline: 2px solid var(--primary) !important;
  outline-offset: -1px;
}
footer {
text-align: center;
margin-top: 20px;
color: var(--text-light);
font-size: 0.9rem;
}

footer a,
footer a:visited,
footer a:hover,
footer a:active {
    color: var(--text-light);
    text-decoration: none;
}

@media (max-width: 1000px) {
.main-layout {
    flex-direction: column;
}
.canvas-area {
    min-width: auto;
    height: 500px; /* ← 移动端也固定 */
}
.tool-area {
    width: 100%;
    max-width: 500px;
    flex: none; /* ← 关键：取消 flex 行为 */
}
}