:root {
  --bg-color: #0f172a;
  --surface-color: #1e293b;
  --surface-border: #334155;
  --surface-hover: #475569;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --secondary-color: #334155;
  --secondary-hover: #475569;
  --accent-color: #10b981;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', Courier, monospace;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  min-height: 100vh;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
.header {
  text-align: center;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 2.2rem;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #a5b4fc 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* Card Component */
.card {
  background-color: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: var(--text-main);
  border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
  border-color: var(--text-muted);
}

.btn-chip {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

.btn-chip:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-chip.active {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

/* Preview Section */
.preview-card {
  position: sticky;
  top: 1.5rem;
}

.preview-actions {
  display: flex;
  gap: 0.5rem;
}

.gradient-preview-box {
  width: 100%;
  height: 260px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-inner, inset 0 2px 4px rgba(0,0,0,0.2));
  position: relative;
  transition: background 0.15s ease-out;
}

.preview-badge {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Code Output */
.code-output-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}

.code-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #090d16;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  gap: 1rem;
  overflow-x: auto;
}

.code-box code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #38bdf8;
  white-space: nowrap;
  word-break: break-all;
}

.copy-btn {
  flex-shrink: 0;
}

.copy-toast {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background-color: var(--accent-color);
  color: #0f172a;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.copy-toast.hidden {
  opacity: 0;
  transform: translateY(5px);
}

/* Controls Section */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Color Controls */
.color-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 480px) {
  .color-controls-grid {
    grid-template-columns: 1fr;
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #090d16;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
}

.color-input-wrapper input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
}

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

.color-input-wrapper input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
}

.color-input-wrapper input[type="text"] {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  text-transform: uppercase;
}

/* Angle Control */
.angle-control-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-header label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

.angle-number-input-wrapper {
  display: flex;
  align-items: center;
  background-color: #090d16;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
}

.angle-number-input-wrapper input[type="number"] {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  width: 50px;
  text-align: right;
  outline: none;
  -moz-appearance: textfield;
}

.angle-number-input-wrapper input[type="number"]::-webkit-inner-spin-button,
.angle-number-input-wrapper input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.angle-number-input-wrapper .unit {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-left: 2px;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-border);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Direction Presets */
.preset-angles {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preset-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.preset-buttons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

@media (max-width: 480px) {
  .preset-buttons-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Preset Templates */
.presets-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

.preset-item {
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background-color: #090d16;
  transition: transform 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}

.preset-item:hover {
  transform: translateY(-2px);
  border-color: var(--primary-color);
}

.preset-preview {
  height: 60px;
  width: 100%;
}

.preset-info {
  padding: 0.4rem 0.6rem;
  text-align: center;
}

.preset-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Footer */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding-top: 1rem;
  border-top: 1px solid var(--surface-border);
}
