.container {
  max-width: 1400px;
  padding: 20px;
}

header h1 {
  font-size: 2rem;
}

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

header span {
  display: block;
  text-align: center;
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-top: 8px;
}

header span a {
  color: var(--primary);
  text-decoration: none;
  margin: 0 6px;
}

header span a:hover {
  text-decoration: underline;
}

.main-content {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 20px;
}

.top-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: stretch;
  padding: 24px;
  background: linear-gradient(135deg, rgba(79,70,229,0.06) 0%, rgba(5,150,105,0.06) 100%);
  border-bottom: 1px solid var(--gray-200);
}

.upload-section {
  flex: 1 1 40%;
  min-width: 260px;
  max-width: 340px;
}

.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--border-radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  min-height: 300px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: #eef2ff;
}

.upload-icon {
  color: var(--gray-400);
  margin-bottom: 12px;
}

.upload-text {
  font-size: 1.1rem;
  color: var(--gray-700);
  margin-bottom: 6px;
  font-weight: 500;
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--gray-400);
}

.file-input {
  display: none;
}

.instructions {
  flex: 1 1 50%;
  min-width: 280px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
}

.instructions h3 {
  color: var(--gray-700);
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: 600;
}

.instructions ol {
  padding-left: 18px;
}

.instructions-content {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.instructions-content ol {
  flex: 1 1 auto;
  padding-left: 18px;
  margin-bottom: 0;
}

.preview-image {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-image img {
  max-width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  background: #fff;
}

.instructions li {
  margin-bottom: 6px;
  color: var(--gray-600);
  font-size: 0.9rem;
  line-height: 1.5;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  align-items: center;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--gray-300);
  margin: 0 4px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 8px 7px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: #fff;
  color: var(--gray-700);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tool-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef2ff;
}

.tool-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rotate-btn:hover:not(:disabled) {
  border-color: #17a2b8;
  color: #17a2b8;
  background: #e6f7f9;
}

.export-btn:hover:not(:disabled) {
  border-color: var(--secondary);
  color: var(--secondary);
  background: #ecfdf5;
}

.print-btn:hover:not(:disabled) {
  border-color: #dc3545;
  color: #dc3545;
  background: #fde8e8;
}

.canvas-container {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--gray-50);
}

.canvas-page {
  position: relative;
  margin-bottom: 20px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  background: white;
}

.canvas-page:hover {
  box-shadow: var(--shadow-lg);
}

.canvas-page.selected {
  outline: 3px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.2), var(--shadow-lg);
}

.page-header {
  background: var(--primary);
  color: white;
  padding: 10px 15px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.page-metrics {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cut-lines-count,
.mask-count {
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
}

.mask-count {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

.canvas-wrapper {
  position: relative;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
}

.mask-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cut-line {
  position: absolute;
  top: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, #ff4757, #ff3742);
  cursor: ew-resize;
  z-index: 10;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(255,71,87,0.5);
  transition: all 0.2s ease;
}

.cut-line:hover {
  width: 6px;
  box-shadow: 0 0 15px rgba(255,71,87,0.7);
}

.cut-line::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: #ff4757;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.a4-mask {
  position: absolute;
  border: 2px solid rgba(79,70,229,0.7);
  background: rgba(79,70,229,0.12);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.6), 0 8px 20px rgba(79,70,229,0.2);
  border-radius: 8px;
  cursor: move;
  pointer-events: auto;
  backdrop-filter: blur(1px);
  transition: box-shadow 0.2s ease;
  z-index: 15;
}

.a4-mask:hover {
  box-shadow: 0 0 0 2px rgba(79,70,229,0.4), 0 12px 24px rgba(79,70,229,0.3);
}

.a4-mask .mask-label {
  position: absolute;
  top: 6px;
  left: 8px;
  background: rgba(79,70,229,0.9);
  color: #fff;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.a4-mask .mask-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(220,53,69,0.9);
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(220,53,69,0.3);
}

.a4-mask .mask-remove:hover {
  background: #dc3545;
}

.a4-mask .mask-resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #4f46e5;
  bottom: -8px;
  right: -8px;
  cursor: nwse-resize;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-state svg {
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.2rem;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 1.1rem;
  color: white;
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.loading-overlay.visible {
  visibility: visible;
  opacity: 1;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.progress-bar {
  width: 280px;
  height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  width: 0%;
  transition: width 0.3s ease;
}

.status-message {
  margin-top: 8px;
  font-size: 0.85rem;
  opacity: 0.9;
}

.error-message,
.success-message {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 0.9rem;
}

.error-message {
  background: #fde8e8;
  color: #721c24;
  border-left: 4px solid #dc3545;
}

.success-message {
  background: #d4edda;
  color: #155724;
  border-left: 4px solid #28a745;
}

@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .top-panel {
    flex-direction: column;
    padding: 16px;
  }

  .upload-section,
  .instructions {
    max-width: 100%;
  }

  .instructions-content {
    flex-direction: column;
  }

  .preview-image {
    max-width: 100%;
    order: 2;
  }

  .toolbar {
    padding: 10px 12px;
    gap: 6px;
  }

  .tool-btn {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  .toolbar-divider {
    display: none;
  }

  header h1 {
    font-size: 1.6rem;
  }
}
