:root {
  /* Dark Futuristic Theme - Matching Project Style */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --bg-card: #151520;
  --bg-card-hover: #1e1e2d;

  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #6b6b7b;

  /* Accent Colors - Blue/Purple/Cyan Gradient */
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #06b6d4 100%);
  --accent-gradient-hover: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #0891b2 100%);

  /* Semantic Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;

  /* Borders & Shadows */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.15);
  --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.15);
  --shadow-glow-strong: 0 0 60px rgba(59, 130, 246, 0.25);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Animated Grid Background */
body::before {
  position: fixed;
  inset: 0;
  content: "";
  background-image:
    linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Gradient Orbs Background */
body::after {
  position: fixed;
  inset: 0;
  content: "";
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59, 130, 246, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139, 92, 246, 0.1), transparent),
    radial-gradient(ellipse 50% 30% at 60% 50%, rgba(6, 182, 212, 0.05), transparent);
  pointer-events: none;
  z-index: 0;
}

/* Ambient Glow - Matching other tools */
.ambient-glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  pointer-events: none;
  z-index: 0;
  animation: float 20s ease-in-out infinite;
}

.ambient-glow--secondary {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
  top: auto;
  bottom: -150px;
  left: -150px;
  right: auto;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* App Container */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.logo-icon svg {
  width: 24px;
  height: 24px;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: all 0.15s ease;
}

.back-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: rgba(139, 92, 246, 0.5);
}

.app-shell {
  position: relative;
  z-index: 1;
  margin-top: 28px;
  margin-bottom: 48px;
}

/* Glass Card Effect */
.hero-card,
.panel {
  background: rgba(21, 21, 32, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.hero-card:hover,
.panel:hover {
  border-color: var(--border-color-hover);
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.5), rgba(139, 92, 246, 0.5), transparent);
}

.eyebrow,
.panel__eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  font-weight: 600;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
  background: linear-gradient(135deg, #fff 0%, #a0a0b0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-text {
  max-width: 48rem;
  margin: 14px 0 0;
  color: var(--text-secondary);
  line-height: 1.7;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.hero-badges span,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: rgba(26, 26, 37, 0.6);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.hero-badges span {
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-cyan);
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(340px, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.panel {
  padding: 24px;
}

.panel__header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.panel__header h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

/* Upload Card */
.upload-card {
  display: block;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border-color);
  background: rgba(18, 18, 26, 0.6);
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.upload-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.upload-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.upload-card:hover::before {
  opacity: 0.05;
}

.upload-card input {
  display: none;
}

.upload-card__title {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
}

.upload-card__meta {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.875rem;
  position: relative;
  z-index: 1;
}

/* Status Box */
.status-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(18, 18, 26, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  line-height: 1.6;
}

.status-box.is-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.status-box.is-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

/* Source Preview */
.source-preview-card {
  margin-top: 18px;
}

.control-group__title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
}

.control-group__title-row h3 {
  font-size: 0.9375rem;
  color: var(--text-primary);
  font-weight: 600;
}

.control-group__title-row span {
  color: var(--accent-cyan);
  font-size: 0.875rem;
  font-weight: 500;
}

.source-preview-frame {
  margin-top: 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: rgba(10, 10, 15, 0.6);
  min-height: 180px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.source-preview-frame img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: contain;
  background: transparent;
}

.source-preview-frame p {
  margin: 0;
  padding: 18px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* Control Groups */
.control-group {
  margin-top: 20px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  cursor: pointer;
  font-size: 0.875rem;
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: rgba(26, 26, 37, 0.6);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip:hover {
  border-color: var(--border-color-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chip.is-active {
  color: #fff;
  border-color: var(--accent-blue);
  background: var(--accent-gradient);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

/* Background color chips - show as color swatches */
#bg-options .chip {
  width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  font-size: 0;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#bg-options .chip::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius-md) - 2px);
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

#bg-options .chip:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Active state - show ring around the color, don't change background */
#bg-options .chip.is-active {
  transform: scale(1.08);
  /* Override the default gradient background */
  background: inherit !important;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue), 0 0 0 6px rgba(59, 130, 246, 0.2);
}

#bg-options .chip.is-active::after {
  border-color: transparent;
}

/* Range Slider */
input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.7);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.control-help {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Meta List */
.meta-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.meta-list div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(18, 18, 26, 0.6);
  border: 1px solid var(--border-color);
}

.meta-list dt {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.meta-list dd {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

/* Canvas Stages */
.canvas-stage,
.preview-stage,
.sheet-preview {
  border-radius: var(--radius-lg);
  background: rgba(10, 10, 15, 0.8);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.canvas-stage,
.preview-stage {
  padding: 18px;
}

.canvas-stage canvas,
.preview-stage canvas,
.sheet-preview canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: var(--radius-md);
  background: transparent;
}

#editor-canvas {
  cursor: grab;
  touch-action: none;
}

#editor-canvas.is-dragging {
  cursor: grabbing;
}

.stage-note {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Download Buttons */
.download-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.action-button {
  min-height: 48px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 18px;
  background: rgba(26, 26, 37, 0.8);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.action-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.action-button:hover:not(:disabled) {
  border-color: var(--accent-blue);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.action-button:hover::before {
  opacity: 0.1;
}

.action-button--primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
}

.action-button--primary::before {
  display: none;
}

.action-button--primary:hover:not(:disabled) {
  box-shadow: var(--shadow-glow-strong);
  transform: translateY(-1px);
}

.action-button--wide {
  grid-column: 1 / -1;
}

.action-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Sheet Preview */
.sheet-preview {
  margin-top: 18px;
  padding: 16px;
}

.sheet-preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sheet-preview__head h3 {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.sheet-preview__head span {
  color: var(--accent-cyan);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Focus States */
button:focus-visible,
.chip:focus-visible,
input:focus-visible,
.upload-card:focus-within {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-card,
.panel {
  animation: fadeIn 0.5s ease-out forwards;
}

.panel:nth-child(2) {
  animation-delay: 0.1s;
}

.panel:nth-child(3) {
  animation-delay: 0.2s;
}

/* Responsive */
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-badges {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1400px);
    margin-top: 12px;
  }

  .hero-card,
  .panel {
    padding: 18px;
    border-radius: var(--radius-lg);
  }

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

  .action-button--wide {
    grid-column: auto;
  }

  .meta-list div {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* Loading Animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Model Loading Bar */
.model-loading {
  margin-top: 10px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  display: none;
}

.model-loading[style*="display: block"],
.model-loading:not([style*="display: none"]) {
  display: block;
}

.loading-bar {
  height: 100%;
  width: 30%;
  background: var(--accent-gradient);
  border-radius: 2px;
  animation: loadingBar 1.5s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

@keyframes loadingBar {
  0% {
    transform: translateX(-100%);
  }
  50% {
    width: 50%;
  }
  100% {
    transform: translateX(400%);
  }
}

/* Checkboard pattern for transparent areas */
.checkboard {
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.03) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}
