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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #252525;
  --border: #333;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #6c5ce7;
  --accent-hover: #7c6cf7;
  --danger: #e74c3c;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Layout */
.container { max-width: 900px; margin: 0 auto; padding: 1.5rem; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 1.4rem; font-weight: 600; }

#lang-toggle {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

/* Login */
#login-screen {
  max-width: 360px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

#login-screen h2 { margin-bottom: 1rem; text-align: center; }

#login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  display: none;
}

/* Forms */
label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.3rem; }

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
}

textarea { resize: vertical; min-height: 80px; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group { margin-bottom: 1rem; }

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.form-row .form-group { flex: 1; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-row input[type="checkbox"] { width: auto; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.gen-info {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-small:hover { background: var(--border); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

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

/* Result */
#result-area { margin-bottom: 2rem; text-align: center; }

#result-area img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

#generate-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  display: none;
}

/* History */
#history-section { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }

#history-section h2 { margin-bottom: 1rem; font-size: 1.1rem; }

.history-actions { margin-bottom: 1rem; }

.history-list { display: flex; flex-direction: column; gap: 1rem; }

.history-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.history-item img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  flex-shrink: 0;
}

.history-meta { flex: 1; font-size: 0.85rem; }
.history-meta .prompt-text { color: var(--text); margin-bottom: 0.3rem; }
.history-meta .meta-line { color: var(--text-muted); font-size: 0.8rem; }

.history-actions-row { margin-top: 0.5rem; display: flex; gap: 0.5rem; }

.no-history { color: var(--text-muted); font-style: italic; }

/* Build info */
.build-info {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 600px) {
  .form-row { flex-direction: column; gap: 0; }
  .history-item { flex-direction: column; }
  .history-item img { width: 100%; height: auto; max-height: 200px; }
}
