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

:root {
  --primary: #6366F1;
  --primary-dark: #4F46E5;
  --primary-light: #818CF8;
  --accent: #06B6D4;
  --accent-dark: #0891B2;
  --bg: #F0F9FF;
  --card-bg: #FFFFFF;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 50%, #EDE9FE 100%);
  min-height: 100vh;
  position: relative;
}

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

/* Header */
header {
  margin-bottom: 30px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo h1 {
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-desc {
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 8px;
}

/* Main content */
.main-content {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 24px;
}

.input-section, .preview-section {
  flex: 1;
  min-width: 320px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* Tabs */
.tabs {
  display: flex;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  transition: color 0.2s;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px 3px 0 0;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-muted);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background-color: rgba(99, 102, 241, 0.04);
  color: var(--primary);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.browse-text {
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}

/* Textarea */
#svg-code {
  width: 100%;
  height: 180px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

#svg-code:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.paste-buttons {
  display: flex;
  gap: 10px;
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  background-color: #F1F5F9;
  color: var(--text);
}

.btn:hover {
  background-color: #E2E8F0;
}

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

.primary-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  border: none;
  font-weight: 600;
}

.primary-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--accent-dark) 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.primary-btn:active {
  transform: translateY(0);
}

/* Preview */
.preview-section h2,
.options-section h2,
.result-section h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.preview-container {
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background-color: #FAFAFA;
  background-image:
    linear-gradient(45deg, #E2E8F0 25%, transparent 25%),
    linear-gradient(-45deg, #E2E8F0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #E2E8F0 75%),
    linear-gradient(-45deg, transparent 75%, #E2E8F0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.no-preview-placeholder {
  color: var(--text-muted);
  text-align: center;
  padding: 30px;
  font-size: 14px;
}

.preview-container svg {
  max-width: 100%;
  max-height: 250px;
}

/* Options section */
.options-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.option-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#bg-color {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
}

#bg-color:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

#padding-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  min-width: 36px;
}

/* Generate button */
#generate-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
}

/* Ad container */
.ad-container {
  margin: 24px 0;
  text-align: center;
  min-height: 90px;
}

/* Results */
.result-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.result-summary {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
  padding: 8px 14px;
  background: rgba(99, 102, 241, 0.06);
  border-radius: var(--radius-sm);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.icon-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  transition: all 0.2s ease;
  background: #FAFAFA;
}

.icon-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.icon-card-preview {
  width: 80px;
  height: 80px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.icon-card-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.icon-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.icon-card-size {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.icon-card-platform {
  font-size: 11px;
  color: var(--text-muted);
}

.icon-card-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.icon-download-btn {
  width: 100%;
  padding: 6px;
  font-size: 12px;
}

/* Footer */
footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

/* RTL support */
html[dir="rtl"] .header-top {
  flex-direction: row-reverse;
}

html[dir="rtl"] .checkbox-label {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  .input-section, .preview-section {
    width: 100%;
  }

  .logo h1 {
    font-size: 20px;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

/* Curvature Comparison Section */
.comparison-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.comparison-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: #FAFAFA;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
}

.comparison-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}

.comparison-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  text-align: center;
}

.canvas-wrapper {
  background: #0F172A; /* Slate-900 for premium dark contrast (CAD style) */
  border-radius: var(--radius-sm);
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.canvas-wrapper canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

.comparison-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
}

/* Corner settings sliders label */
.slider-label {
  font-size: 13px;
  color: var(--text-muted);
  width: 75px;
  display: inline-block;
  font-weight: 500;
}

#corner-settings-group .slider-row {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
}

#corner-settings-group .slider {
  flex: 1;
}

#corner-radius-value, #corner-smoothing-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  min-width: 48px;
  text-align: right;
}

/* Preview Clip Path - Applied dynamically to SVG elements */
.preview-container svg {
  clip-path: url(#preview-clip);
  transition: clip-path 0.3s ease;
}

