:root {
  --bg: #0f0f0f;
  --surface: #181818;
  --surface2: #222222;
  --border: #2a2a2a;
  --accent: #7c5cfc;
  --accent-hover: #9278fd;
  --text: #f0f0f0;
  --text-muted: #888;
  --success: #2ecc71;
  --error: #e74c3c;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
}

.logo .tag {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  transition: background 0.3s;
}

.dot.ok { background: var(--success); }
.dot.error { background: var(--error); }

/* ── Main ── */
main {
  flex: 1;
  padding: 28px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.workspace {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  align-items: start;
}

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

/* ── Panel ── */
.panel h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
}

.card-icon { font-size: 16px; }

.badge {
  margin-left: auto;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
}

/* ── Dropzone ── */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  min-height: 130px;
  transition: border-color 0.2s;
  overflow: hidden;
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.05);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  text-align: center;
  gap: 6px;
}

.drop-icon {
  font-size: 28px;
  color: var(--text-muted);
  line-height: 1;
}

.dropzone-inner p {
  font-size: 13px;
  color: var(--text-muted);
}

.hint { font-size: 11px !important; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}

/* ── Image Grid ── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 8px;
}

.image-grid:empty { display: none; }

.image-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--surface2);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-thumb .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.7);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.image-thumb .img-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  font-size: 10px;
  color: #ccc;
  padding: 3px 6px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* ── Textarea ── */
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 12px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.2s;
}

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

textarea::placeholder { color: var(--text-muted); }

/* ── Ratio Grid ── */
.ratio-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  transition: all 0.15s;
}

.ratio-btn:hover { border-color: var(--accent); color: var(--text); }
.ratio-btn.active { border-color: var(--accent); color: var(--text); background: rgba(124,92,252,0.1); }

.ratio-preview {
  background: var(--text-muted);
  border-radius: 2px;
}

.ratio-preview.square       { width: 22px; height: 22px; }
.ratio-preview.landscape43  { width: 26px; height: 20px; }
.ratio-preview.portrait34   { width: 20px; height: 26px; }
.ratio-preview.landscape169 { width: 30px; height: 17px; }
.ratio-preview.portrait916  { width: 17px; height: 30px; }

/* ── Generate Button ── */
.generate-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.generate-btn:hover { background: var(--accent-hover); }
.generate-btn:active { transform: scale(0.99); }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Output ── */
.output-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.placeholder-icon {
  font-size: 48px;
  opacity: 0.3;
}

.output-placeholder p { font-size: 14px; }

.output-image-wrap {
  width: 100%;
}

.output-image-wrap img {
  width: 100%;
  display: block;
  border-radius: var(--radius) var(--radius) 0 0;
}

.output-actions {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.action-btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s;
}

.action-btn:hover { background: var(--accent-hover); }
.action-btn.secondary { background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); }
.action-btn.secondary:hover { color: var(--text); border-color: #555; background: #2a2a2a; }

.output-meta {
  padding: 8px 16px 14px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Error ── */
.error-box {
  margin-top: 14px;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: #e74c3c;
}

/* ── Utilities ── */
.hidden { display: none !important; }
