:root {
  --bg: #0f1420;
  --bg-panel: #171d2e;
  --bg-card: #1f2740;
  --border: #2b3350;
  --text: #eef1f8;
  --text-dim: #9aa4c0;
  --accent: #6c8cff;
  --accent-2: #ff9ecb;
  --accent-3: #7ee6c0;
  --danger: #ff6b6b;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(160deg, #0f1420 0%, #141a2c 60%, #171225 100%);
  color: var(--text);
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.brand-badge {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #10131f;
}

.brand h1 { font-size: 18px; margin: 0; }
.brand span { color: var(--text-dim); font-size: 12px; }

.login-card h2 { font-size: 15px; color: var(--text-dim); font-weight: 500; margin: 20px 0 18px; }

label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  background: #0f1420;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

button.btn {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .1s, opacity .15s;
}
button.btn:active { transform: scale(0.98); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8f6cff);
  color: #fff;
  width: 100%;
  margin-top: 22px;
}

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

.error-msg {
  background: rgba(255,107,107,.12);
  border: 1px solid rgba(255,107,107,.35);
  color: #ffb3b3;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}

.hint { font-size: 11px; color: var(--text-dim); margin-top: 18px; line-height: 1.5; }

/* ---------- Dashboard ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(15,20,32,.85);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}

.topbar .brand h1 { font-size: 16px; }

.app-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  min-height: calc(100vh - 61px);
}

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

.panel {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 22px;
  overflow-y: auto;
}

.panel h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  margin: 22px 0 10px;
}
.panel h3:first-child { margin-top: 0; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active {
  background: linear-gradient(135deg, var(--accent), #8f6cff);
  border-color: transparent;
  color: #fff;
}

.seg { display: flex; gap: 8px; }
.seg .chip { flex: 1; text-align: center; }

.content { padding: 24px; }

.prompt-preview {
  background: #0f1420;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  max-height: 90px;
  overflow-y: auto;
  font-family: Consolas, monospace;
}

.gen-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.progress-wrap {
  flex: 1;
  min-width: 200px;
  height: 8px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
  display: none;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-3), var(--accent));
  transition: width .3s;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.card-img {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img .placeholder { color: var(--text-dim); font-size: 12px; text-align: center; padding: 10px; }
.card-img .spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card-actions {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; gap: 6px; padding: 8px;
  background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
  opacity: 0; transition: opacity .15s;
}
.card-img:hover .card-actions { opacity: 1; }
.card-actions button {
  flex: 1; font-size: 11px; padding: 6px;
  background: rgba(255,255,255,.15); color: #fff; border: none; border-radius: 6px; cursor: pointer;
}
.card-actions button:hover { background: rgba(255,255,255,.3); }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
  font-size: 13px;
}

.badge-free {
  display: inline-block;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(126,230,192,.15);
  color: var(--accent-3);
  border: 1px solid rgba(126,230,192,.3);
  margin-left: 8px;
}

.history-list { display: flex; flex-direction: column; gap: 4px; }
.history-item {
  font-size: 12px; color: var(--text-dim);
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.history-item:hover { background: var(--bg-card); border-color: var(--border); }

.user-box { display: flex; align-items: center; gap: 10px; }
.user-box .name { font-size: 13px; }
.user-box button { background: none; border: 1px solid var(--border); color: var(--text-dim); border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.user-box button:hover { color: var(--text); border-color: var(--danger); }
