/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:       #0f0f1a;
  --surface:  #1a1a2e;
  --border:   #2e2e4e;
  --accent:   #4fc3f7;
  --accent2:  #7c4dff;
  --text:     #e0e0f0;
  --muted:    #888aaa;
  --error:    #ff5252;
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,.5);
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
  padding: 1.5rem 1rem 4rem;
}

/* ── Layout ──────────────────────────────────────────────── */
.container { max-width: 960px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow);
}
.center { text-align: center; }

/* ── Header ──────────────────────────────────────────────── */
header { text-align: center; padding: 1rem 0 .25rem; }
header h1 {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle { color: var(--muted); margin-top: .4rem; }

/* ── Form ────────────────────────────────────────────────── */
h2 { font-size: 1.2rem; margin-bottom: 1rem; color: var(--accent); }
h3 { font-size: 1rem; margin-bottom: .75rem; color: var(--accent); }

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.25rem; }
.field label { font-weight: 600; }
.hint { font-size: .8rem; color: var(--muted); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr; } }

input[type="file"],
input[type="number"],
input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: .55rem .75rem;
  font-size: 1rem;
  transition: border-color .2s;
}
input[type="number"],
input[type="text"] { width: 100%; }
input:focus { outline: none; border-color: var(--accent); }

/* ── Thumbnail ───────────────────────────────────────────── */
.preview-thumb {
  margin-top: .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: inline-block;
  background: repeating-conic-gradient(#333 0% 25%, #222 0% 50%) 0 0 / 16px 16px;
}
.preview-thumb img {
  display: block;
  max-height: 150px;
  max-width: 100%;
  image-rendering: pixelated;
}

/* ── Advanced settings ───────────────────────────────────── */
.settings-details {
  margin-top: .5rem;
  margin-bottom: 1.25rem;
}
.settings-toggle {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  padding: .5rem 0;
  user-select: none;
}
.settings-toggle:hover { opacity: .85; }
.settings-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.25rem .25rem;
  margin-top: .75rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  display: inline-block;
  padding: .65rem 1.5rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: opacity .15s, transform .1s;
}
.btn-primary:hover, .btn-secondary:hover { opacity: .88; transform: translateY(-1px); }
.btn-primary:active, .btn-secondary:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  margin-top: .5rem;
}
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-top: .5rem;
}

/* ── Error ───────────────────────────────────────────────── */
.error {
  color: var(--error);
  font-size: .9rem;
  margin-top: .75rem;
  padding: .5rem .75rem;
  border: 1px solid var(--error);
  border-radius: 6px;
  background: rgba(255,82,82,.08);
}

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result grid ─────────────────────────────────────────── */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: .5rem;
}
@media (max-width: 700px) { .result-grid { grid-template-columns: 1fr; } }

.result-col h3 {
  text-align: center;
  margin-bottom: .5rem;
}

/* ── 3-D preview canvas ──────────────────────────────────── */
.preview-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: .75rem;
  background: #1a1a2e;
}
.preview-wrap canvas { display: block; width: 100% !important; cursor: grab; }
.preview-wrap canvas:active { cursor: grabbing; }

/* ── Actions row ─────────────────────────────────────────── */
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; }
