:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --primary-light: #e3f2fd;
    --gray: #95a5a6;
    --dark: #2c3e50;
    --light-bg: #f8f9fa;
    --text-light: #666;
    --border-radius: 8px;
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
  }
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #f0f7ff, #e3f2fd);
    color: var(--dark);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
  }
  
  .container {
    max-width: 1000px;
    margin: 0 auto;
  }
  
  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;
  }
  
  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;
  }

  .upload-area {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    transition: all 0.3s;
    border: 2px dashed #cbd5e0;
  }
  
  .upload-area.drag-over {
    background: #e3f2fd;
    border-color: var(--primary);
    transform: scale(1.02);
  }
  
  .upload-inner {
    max-width: 400px;
    margin: 0 auto;
  }
  
  .upload-btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 12px 28px;
    font-size: 1.05rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-weight: 600;
  }
  
  .upload-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.3);
  }
  
  .upload-btn input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
  }
  
  .hint {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--gray);
  }
  
  .canvas-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
  }
  
  .canvas-container {
    position: relative;
    background: white;
    width: 100%;
    overflow: hidden;
  }
  
  #canvas {
    display: block;
    background: #fafafa;
    width: 100%;
    min-height: 500px;
    cursor: crosshair;
  }
  
  .crop-dimensions {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(52, 152, 219, 0.9);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    z-index: 20;
    pointer-events: none;
    font-family: 'Menlo', 'Consolas', monospace; /* 等宽字体，对齐数字 */
    letter-spacing: 0.5px;
  }
  
  /* ✅ 关键修复：toolbar 独立定位 + 高层级 + 强制点击 */
  .toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 10px;
    z-index: 1000;
    pointer-events: auto !important;
  }
  
  .btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    min-width: 120px;
    pointer-events: auto !important;
  }
  
  .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
  }
  
  .btn.primary {
    background: var(--primary);
    color: white;
  }
  
  .btn.primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
  }
  
  .btn.secondary {
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
  }
  
  .btn.secondary:hover:not(:disabled) {
    background: var(--primary-light);
  }
  
  .instructions {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
  }
  
  .instructions h3 {
    color: var(--primary);
    margin-bottom: 12px;
  }
  
  .instructions ul {
    padding-left: 20px;
  }
  
  .instructions li {
    margin-bottom: 8px;
  }
  
  kbd {
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.9em;
  }
  
  /* 裁剪框样式 */
  .crop-box {
    position: absolute;
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
    pointer-events: none;
    z-index: 10;
  }
  
  .crop-box.active {
    pointer-events: auto;
  }
  
  .handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50%;
    pointer-events: auto;
    z-index: 15;
  }
  
  .handle.n, .handle.s { cursor: ns-resize; }
  .handle.e, .handle.w { cursor: ew-resize; }
  .handle.ne, .handle.sw { cursor: nesw-resize; }
  .handle.nw, .handle.se { cursor: nwse-resize; }
  
  .handle.n { top: -6px; left: 50%; transform: translateX(-50%); }
  .handle.s { bottom: -6px; left: 50%; transform: translateX(-50%); }
  .handle.e { right: -6px; top: 50%; transform: translateY(-50%); }
  .handle.w { left: -6px; top: 50%; transform: translateY(-50%); }
  .handle.ne { top: -6px; right: -6px; }
  .handle.nw { top: -6px; left: -6px; }
  .handle.se { bottom: -6px; right: -6px; }
  .handle.sw { bottom: -6px; left: -6px; }
  
  /* 响应式 */
  @media (max-width: 768px) {
    .toolbar {
      top: 8px;
      right: 8px;
      flex-direction: column;
    }
    .btn { min-width: 100px; padding: 6px 12px; font-size: 0.85rem; }
    .crop-dimensions { top: 8px; left: 8px; font-size: 0.8rem; padding: 3px 8px; }
    header h1 { font-size: 1.8rem; }
    .upload-area { padding: 16px; }
  }