:root {
  /* Colors - Elegant Palette */
  --primary: #4F46E5; /* Indigo */
  --primary-hover: #4338CA;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --bg-body: #F3F4F6; /* Cool Gray */
  --bg-card: #FFFFFF;
  --text-main: #111827;
  --text-secondary: #6B7280;
  --text-placeholder: #9CA3AF;
  --border-light: #E5E7EB;
  --input-bg: #F9FAFB;
  --input-focus-ring: rgba(79, 70, 229, 0.1); /* Reduced opacity for lighter glow */
  --error: #EF4444;

  /* Radius */
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;

  /* Shadows - Soft & Deep */
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.03);
  
  /* Header & Footer */
  --header-height: 64px;

  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header */
.site-header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.5);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 24px;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.logo-icon {
  font-size: 32px;
  filter: drop-shadow(0 2px 4px rgba(79, 70, 229, 0.3));
}

.logo-text {
  background: linear-gradient(135deg, var(--text-main) 0%, #4F46E5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-tag {
  background: #EEF2FF;
  color: #4F46E5;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Footer */
.site-footer {
  margin-top: auto;
  padding: 40px 0;
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  min-height: calc(100vh - var(--header-height) - 100px); /* Adjust for header/footer */
  align-items: stretch;
}

.left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card:last-child {
  display: flex;
  flex-direction: column;
  overflow: hidden; 
}

.card:last-child .card-title {
  flex-shrink: 0;
}

textarea {
  resize: vertical; /* Allow vertical resize */
  min-height: 80px;
  line-height: 1.6;
}

.actions {
  flex-shrink: 0;
  display: flex;
  gap: 16px;
  margin-top: 24px; /* Increased margin from text area */
}

.right {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
}

/* Card Refinements */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  border: 1px solid var(--border-light);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  display: block;
  width: 3px;
  height: 16px;
  background: var(--primary);
  border-radius: 1.5px;
}

/* Upload */
.upload-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-body);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--border-light);
  transition: var(--transition);
}

.upload-row:hover {
  border-color: var(--primary);
  background: #eff6ff;
}

.file-name {
  color: var(--text-secondary);
  font-size: 14px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Forms */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 2px;
}

.inline {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

/* Restoring Spin Buttons for Numeric Inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: auto; /* Restore default appearance */
  margin: 0;
  opacity: 0.6; /* Subtle visibility */
}

input[type="number"]:hover::-webkit-inner-spin-button,
input[type="number"]:hover::-webkit-outer-spin-button {
  opacity: 1;
}

input[type="number"] {
  -moz-appearance: textfield; /* Keep textfield for Firefox but can be overridden if needed */
}

/* Input Refinements */
input[type="number"],
input[type="text"],
textarea,
select {
  border: 1px solid var(--border-light);
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 12px 40px 12px 16px; /* Reduced right padding */
  font-size: 14px;
  width: 100%;
  color: var(--text-main);
  transition: var(--transition);
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}



input[type="number"]:focus,
input[type="text"]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
  outline: none;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 14px center; /* Moved slightly left (default is usually closer to edge) */
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 40px;
}

textarea {
  resize: vertical; /* Allow vertical resize */
  min-height: 80px;
  line-height: 1.6;
}

.suffix {
  position: absolute;
  right: 20px; /* Adjusted to be closer to spinner */
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 13px;
  pointer-events: none;
  background: transparent;
  padding-right: 4px;
}

/* Color Picker Customization */
input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  background: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius-md);
}

.hex {
  font-family: monospace;
  color: var(--text-secondary);
  font-size: 13px;
  background: var(--input-bg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  min-width: 80px;
  text-align: center;
}

/* Buttons */
/* .actions rule removed to avoid duplication and conflict */

/* Button Refinements */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-size: 14px;
  font-family: inherit;
}

.btn.primary {
  background: var(--primary);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0));
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), 0 4px 6px -1px rgba(79, 70, 229, 0.3);
  border: 1px solid rgba(0,0,0,0.05);
}

.btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3), 0 4px 6px -2px rgba(79, 70, 229, 0.15); /* Reduced opacity */
  transform: translateY(-1px);
}

.btn.secondary {
  background: #FFFFFF;
  color: var(--text-main);
  border: 1px solid var(--border-light);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn.secondary:hover {
  background: #F9FAFB;
  border-color: #D1D5DB;
  color: #111827;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(1);
  box-shadow: none;
}

/* Preview Area */
.preview-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0; /* Remove padding for immersive preview */
  background: var(--bg-card); /* Ensure background is white */
  height: 100%; /* Fill the right column height */
  min-height: 500px; /* Ensure minimum visibility */
}

.preview-card .card-title {
  padding: 24px 24px 16px;
  flex-shrink: 0;
}

.preview-area {
  flex: 1; /* Fill the remaining height */
  width: 100%;
  background-color: #e5e7eb; /* Neutral gray */
  background-image: radial-gradient(#d1d5db 1px, transparent 1px);
  background-size: 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-top: 1px solid var(--border-light);
  padding: 24px; /* Add padding inside the gray area */
}

.canvas {
  max-width: 95%;
  max-height: 95%;
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  object-fit: contain;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-placeholder);
  text-align: center;
}

.placeholder-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.placeholder-text {
  font-size: 15px;
  font-weight: 500;
}

/* Error State */
.error {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* Responsive */
@media (max-width: 960px) {
  .container {
    grid-template-columns: 1fr;
    max-width: 600px;
  }
  
  .right {
    position: static;
    height: auto;
    min-height: 500px;
  }
}
