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

:root {
  --bg-primary: #0d0d1a;
  --bg-secondary: #1a1a2e;
  --bg-card: rgba(26, 26, 46, 0.7);
  --cyan: #00d4ff;
  --magenta: #ff00aa;
  --purple: #7b2cbf;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --border-glow: rgba(0, 212, 255, 0.3);
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.particle-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Floating Cube */
.floating-cube {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  transform-style: preserve-3d;
  animation: cubeRotate 8s infinite linear;
  z-index: 100;
}

.cube-face {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 2px solid var(--cyan);
  background: rgba(0, 212, 255, 0.1);
  box-shadow: 0 0 10px var(--cyan);
}

.front { transform: translateZ(20px); }
.back { transform: translateZ(-20px) rotateY(180deg); }
.right { transform: rotateY(90deg) translateZ(20px); }
.left { transform: rotateY(-90deg) translateZ(20px); }
.top { transform: rotateX(90deg) translateZ(20px); }
.bottom { transform: rotateX(-90deg) translateZ(20px); }

@keyframes cubeRotate {
  from { transform: rotateX(0) rotateY(0); }
  to { transform: rotateX(360deg) rotateY(360deg); }
}

/* Header */
.header {
  text-align: center;
  padding: 2rem 1rem;
  position: relative;
}

.title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.gradient-text {
  background: linear-gradient(135deg, var(--purple), var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 5s ease infinite;
  background-size: 200% 200%;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.1);
}

/* Main Content */
.main-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: 0 1rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

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

/* Input Section */
.input-section {
  padding: 1.5rem;
}

.prompt-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1rem;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  resize: vertical;
  min-height: 100px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.prompt-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

.prompt-input::placeholder {
  color: var(--text-secondary);
}

/* Example Chips */
.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.chip {
  background: rgba(123, 44, 191, 0.2);
  border: 1px solid rgba(123, 44, 191, 0.4);
  color: var(--text-primary);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Space Grotesk', sans-serif;
}

.chip:hover {
  background: rgba(123, 44, 191, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(123, 44, 191, 0.3);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.generate-btn {
  flex: 1;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  color: white;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Space Grotesk', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(123, 44, 191, 0.4);
}

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

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.random-btn {
  padding: 1rem 1.5rem;
  background: rgba(255, 0, 170, 0.2);
  border: 1px solid rgba(255, 0, 170, 0.4);
  color: var(--text-primary);
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  transition: all 0.3s;
}

.random-btn:hover {
  background: rgba(255, 0, 170, 0.4);
  transform: translateY(-2px);
}

/* History */
.history {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.history-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.history-item {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
  color: var(--cyan);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Space Grotesk', sans-serif;
}

.history-item:hover {
  background: rgba(0, 212, 255, 0.2);
}

/* Preview Section */
.preview-container {
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-btn {
  background: rgba(0, 212, 255, 0.2);
  border: 1px solid rgba(0, 212, 255, 0.3);
  color: var(--cyan);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  transition: all 0.3s;
}

.preview-btn:hover {
  background: rgba(0, 212, 255, 0.3);
}

.preview-frame {
  flex: 1;
  position: relative;
  background: 
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
}

.preview-iframe {
  width: 100%;
  height: 100%;
  min-height: 350px;
  border: none;
  display: block;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 350px;
  color: var(--text-secondary);
}

.placeholder-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.placeholder-sub {
  font-size: 0.85rem;
  opacity: 0.6;
  margin-top: 0.5rem;
}

/* Code Section */
.code-section {
  padding: 0 1rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.code-container {
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.code-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.code-dot.red { background: #ff5f56; }
.code-dot.yellow { background: #ffbd2e; }
.code-dot.green { background: #27ca40; }

.code-label {
  margin-left: 0.5rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

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

.code-btn {
  background: rgba(0, 212, 255, 0.15);
  border: 1px solid rgba(0, 212, 255, 0.3);
  color: var(--cyan);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  transition: all 0.3s;
}

.code-btn:hover {
  background: rgba(0, 212, 255, 0.25);
}

.code-btn.copied {
  background: rgba(39, 202, 64, 0.2);
  border-color: rgba(39, 202, 64, 0.4);
  color: #27ca40;
}

.code-content {
  display: flex;
  max-height: 400px;
  overflow: auto;
}

.line-numbers {
  display: flex;
  flex-direction: column;
  padding: 1rem 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  text-align: right;
  user-select: none;
  line-height: 1.5;
}

.line-numbers span {
  padding: 0 0.5rem;
}

.code-text {
  flex: 1;
  padding: 1rem;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #e0e0e0;
  white-space: pre;
  overflow-x: auto;
}

/* Sidebar */
.sidebar {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  transition: all 0.3s;
}

.sidebar-toggle {
  position: absolute;
  left: -40px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--cyan);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-content {
  width: 0;
  overflow: hidden;
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glow);
  border-radius: 16px 0 0 16px;
  transition: all 0.3s;
}

.sidebar.open .sidebar-content {
  width: 260px;
  padding: 1.5rem;
}

.sidebar-content h3 {
  margin-bottom: 1.5rem;
  font-size: 1rem;
  color: var(--cyan);
}

.setting-group {
  margin-bottom: 1.2rem;
}

.setting-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.setting-group input[type="color"] {
  width: 100%;
  height: 36px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
}

.setting-group input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.setting-group.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-group.toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--cyan);
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer a {
  color: var(--cyan);
  text-decoration: none;
  transition: color 0.3s;
}

.footer a:hover {
  color: var(--magenta);
}

.footer-sep {
  opacity: 0.4;
}

.attribution {
  opacity: 0.6;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 212, 255, 0.5);
}

/* Mobile Adjustments */
@media (max-width: 600px) {
  .floating-cube {
    width: 30px;
    height: 30px;
    top: 10px;
    right: 10px;
  }
  
  .cube-face {
    width: 30px;
    height: 30px;
  }
  
  .front { transform: translateZ(15px); }
  .back { transform: translateZ(-15px) rotateY(180deg); }
  .right { transform: rotateY(90deg) translateZ(15px); }
  .left { transform: rotateY(-90deg) translateZ(15px); }
  .top { transform: rotateX(90deg) translateZ(15px); }
  .bottom { transform: rotateX(-90deg) translateZ(15px); }
  
  .header {
    padding: 1.5rem 1rem;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .code-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .sidebar.open .sidebar-content {
    width: 220px;
    padding: 1rem;
  }
}