/* AI Image Generator — dark studio theme */
:root {
  --bg: #0f1222;
  --bg2: #161a30;
  --panel: #1b2038;
  --panel2: #232a47;
  --line: #2e3658;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7c6cf6;
  --accent2: #b36cf6;
  --danger: #f66c6c;
  --radius: 14px;
}

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

body {
  font-family: "Noto Sans Myanmar", "Myanmar Text", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #232a52 0%, var(--bg) 55%) fixed,
              radial-gradient(900px 500px at 110% 10%, #3a2352 0%, transparent 60%) fixed,
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }

/* Header */
.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; background: rgba(27, 32, 56, 0.8); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo { font-size: 34px; }
.brand h1 { font-size: 20px; }
.brand p { font-size: 13px; color: var(--muted); }
.lang-toggle { display: flex; gap: 6px; }
.lang-btn {
  background: var(--panel2); color: var(--muted); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.lang-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Panels */
.main { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .main { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}

.field-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: block; font-weight: 600; }

textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px; font-size: 15px; resize: vertical; font-family: inherit;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124, 108, 246, 0.25); }

.row { margin-top: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  font-size: 12.5px; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: #fff; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.example { border-style: dashed; color: var(--muted); }

/* Controls grid */
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
@media (max-width: 520px) { .controls-grid { grid-template-columns: 1fr; } }

select, input[type="number"] {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.aspect-btns { display: flex; gap: 8px; }
.aspect-btn {
  flex: 1; background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 10px; padding: 10px 0; cursor: pointer; font-size: 14px; font-family: inherit;
}
.aspect-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.seed-row { display: flex; gap: 8px; }
.icon-btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 14px; font-size: 18px; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }

/* Toggle switch */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--text); }
.switch input { display: none; }
.slider {
  width: 42px; height: 24px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 999px; position: relative; flex-shrink: 0; transition: background 0.2s;
}
.slider::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: var(--muted); border-radius: 50%; transition: all 0.2s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::after { left: 20px; background: #fff; }

/* Generate button */
.generate-btn {
  width: 100%; margin-top: 18px; padding: 15px; font-size: 17px; font-weight: 700;
  font-family: inherit; color: #fff; cursor: pointer; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 24px rgba(124, 108, 246, 0.4); transition: transform 0.1s, opacity 0.2s;
}
.generate-btn:hover:not(:disabled) { transform: translateY(-1px); }
.generate-btn:disabled { opacity: 0.6; cursor: wait; }
.btn-icon { margin-right: 6px; }

/* Result panel */
.result-panel { display: flex; flex-direction: column; min-height: 420px; }
.result-empty, .result-loading, .result-error {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--muted); text-align: center; padding: 30px;
}
.empty-art { font-size: 56px; opacity: 0.6; }
.error-art { font-size: 48px; }
.hidden { display: none !important; }

.spinner {
  width: 52px; height: 52px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#resultImg {
  width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block;
  background: var(--bg2);
}
.result-prompt { margin-top: 12px; font-size: 13.5px; color: var(--muted); word-break: break-word; }
.result-actions { display: flex; gap: 10px; margin-top: 12px; }
.secondary-btn {
  flex: 1; padding: 11px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  font-size: 14px; font-family: inherit;
}
.secondary-btn:hover { border-color: var(--accent); }

/* History */
.history {
  margin-top: 18px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.history-head h2 { font-size: 16px; }
.danger-btn {
  background: transparent; color: var(--danger); border: 1px solid var(--danger);
  border-radius: 10px; padding: 7px 14px; cursor: pointer; font-size: 13px; font-family: inherit;
}
.danger-btn:hover { background: rgba(246, 108, 108, 0.12); }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.history-item {
  position: relative; cursor: pointer; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); aspect-ratio: 1; background: var(--bg2);
}
.history-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.history-item:hover { border-color: var(--accent); }
.history-item .h-prompt {
  position: absolute; bottom: 0; left: 0; right: 0; font-size: 11px; padding: 4px 6px;
  background: rgba(0, 0, 0, 0.65); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 18px 0; }

.footer { text-align: center; margin-top: 22px; color: var(--muted); font-size: 12.5px; }
