* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #ffffff; --bg2: #f5f5f5; --bg3: #ebebeb;
  --text: #111; --text2: #666; --text3: #999;
  --border: #e0e0e0; --accent: #111; --accent-t: #fff;
  --card: #ffffff; --code: #1e1e1e;
  --purple: #7c3aed; --purple-light: #ede9fe;
}

[data-theme="dark"] {
  --bg: #0d0d0d; --bg2: #171717; --bg3: #252525;
  --text: #eee; --text2: #999; --text3: #555;
  --border: #2a2a2a; --accent: #eee; --accent-t: #0d0d0d;
  --card: #171717; --code: #0a0a0a;
  --purple-light: #1a1030;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  height: 100vh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

/* AUTH / ULTRA WALLS */
.auth-wall, .ultra-wall {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.auth-box { text-align: center; max-width: 380px; padding: 40px; }
.auth-logo { width: 44px; margin-bottom: 20px; }
.auth-box h2 { font-size: 22px; margin-bottom: 8px; }
.auth-box p { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.auth-link-btn {
  display: inline-block; padding: 10px 28px; background: var(--accent);
  color: var(--accent-t); border-radius: 10px; text-decoration: none;
  font-size: 14px; font-weight: 500;
}
.ultra-icon { font-size: 40px; margin-bottom: 16px; }
.current-plan { font-size: 13px; color: var(--text3); margin-top: 8px; }
.current-plan span { color: var(--text); font-weight: 600; }

/* NAV */
.flux-nav {
  height: 48px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0;
}
.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 15px;
}
.nav-logo img { width: 22px; }
.nav-version {
  font-size: 11px; background: var(--purple-light); color: var(--purple);
  padding: 2px 8px; border-radius: 6px; font-weight: 600;
}
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-credits { font-size: 12px; color: var(--text3); }
.nav-user { font-size: 13px; color: var(--text2); }
.theme-btn {
  background: none; border: none; color: var(--text2); cursor: pointer;
  display: flex; align-items: center; padding: 4px;
}

/* BODY LAYOUT */
.flux-body {
  display: flex; flex: 1; height: calc(100vh - 48px); overflow: hidden;
}
.flux-app { display: flex; flex-direction: column; height: 100vh; }

/* CONTROLS */
.controls {
  width: 300px; background: var(--bg2); border-right: 1px solid var(--border);
  padding: 20px; overflow-y: auto; flex-shrink: 0;
  transition: background 0.3s;
}
.controls h3 { font-size: 14px; font-weight: 600; margin-bottom: 20px; }

.ctrl-label {
  display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; margin-top: 16px;
}
.ctrl-label:first-of-type { margin-top: 0; }

.controls textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; font-family: inherit; resize: vertical; outline: none;
  background: var(--bg); color: var(--text); transition: border-color 0.2s;
  min-height: 80px;
}
.controls textarea:focus { border-color: var(--text3); }
.controls textarea::placeholder { color: var(--text3); }

.cfg-hint { font-size: 11px; color: var(--text3); margin-bottom: 6px; }

input[type="range"] {
  width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
  background: var(--border); border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

.ctrl-fixed {
  margin-top: 20px; padding: 12px; background: var(--bg); border-radius: 10px;
  border: 1px solid var(--border);
}
.ctrl-row {
  display: flex; justify-content: space-between; font-size: 12px;
  padding: 4px 0; color: var(--text2);
}
.ctrl-row span:last-child { color: var(--text); font-weight: 500; }

.generate-btn {
  width: 100%; margin-top: 20px; padding: 12px; background: var(--accent);
  color: var(--accent-t); border: none; border-radius: 10px; font-size: 14px;
  font-weight: 500; font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity 0.15s;
}
.generate-btn:hover { opacity: 0.85; }
.generate-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* RESULT AREA */
.result-area {
  flex: 1; overflow-y: auto; padding: 40px; display: flex;
  flex-direction: column; align-items: center;
}

.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { color: var(--text2); font-size: 14px; }

/* LOADING */
.loading {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
}
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.loading-sub { font-size: 13px; color: var(--text3); }

/* VIDEO */
.video-result { width: 100%; max-width: 500px; text-align: center; }
.video-result video {
  width: 100%; border-radius: 12px; background: #000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.video-info { margin-top: 16px; }
.video-prompt { font-size: 13px; color: var(--text2); margin-bottom: 8px; }
.video-meta { font-size: 12px; color: var(--text3); margin-bottom: 12px; }
.download-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: 8px; text-decoration: none;
  color: var(--text); font-size: 13px; transition: background 0.15s;
}
.download-btn:hover { background: var(--bg2); }

/* ERROR */
.error-state { text-align: center; }
.error-icon { font-size: 36px; margin-bottom: 12px; }
.error-text { color: #ef4444; font-size: 14px; margin-bottom: 16px; }
.retry-btn {
  padding: 8px 20px; border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--text); font-size: 13px;
  cursor: pointer; font-family: inherit;
}

/* HISTORY */
.history { width: 100%; max-width: 700px; margin-top: 32px; }
.history h3 { font-size: 14px; color: var(--text2); margin-bottom: 12px; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.history-item {
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
  cursor: pointer; transition: transform 0.15s;
}
.history-item:hover { transform: scale(1.02); }
.history-item video { width: 100%; display: block; }
.history-item-info { padding: 8px 10px; font-size: 11px; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 768px) {
  .flux-body { flex-direction: column; }
  .controls { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .result-area { padding: 20px; }
}
