/* ── Reset & base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #1a1209;
  --surface:   #2b1d0e;
  --border:    #4a3520;
  --amber:     #e8890c;
  --amber-dim: #c4720a;
  --text:      #f0dfc0;
  --text-dim:  #a08060;
  --radius:    10px;
  --error:     #e05555;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}
header h1 { font-size: 2rem; color: var(--amber); }
header p  { color: var(--text-dim); margin-top: .4rem; }

/* ── Layout ─────────────────────────────────────────────────────── */
main {
  display: flex;
  gap: 2rem;
  width: 100%;
  max-width: 900px;
  flex-wrap: wrap;
}

.controls-panel {
  flex: 1 1 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.preview-panel {
  flex: 1 1 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 340px;
  position: relative;
  overflow: hidden;
}

/* ── Form fields ────────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 1.2rem; }

.field-group { display: flex; flex-direction: column; gap: .4rem; }

label { font-size: .85rem; color: var(--text-dim); font-weight: 600; }

input[type="url"],
input[type="text"],
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .95rem;
  padding: .5rem .75rem;
  width: 100%;
  outline: none;
  transition: border-color .2s;
}
input:focus, select:focus { border-color: var(--amber); }

input.input-error { border-color: var(--error) !important; }

.url-row { display: flex; gap: .5rem; }
.url-row input { flex: 1; }

input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
}

/* ── Radio buttons ──────────────────────────────────────────────── */
.radio-row { display: flex; gap: 1.5rem; }
.radio-label {
  display: flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  color: var(--text);
  font-size: .95rem;
  font-weight: normal;
}
input[type="radio"] { accent-color: var(--amber); }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  padding: .6rem 1.2rem;
  transition: background .2s, opacity .2s;
}

.btn-primary {
  background: var(--amber);
  color: #1a1209;
  width: 100%;
}
.btn-primary:hover  { background: var(--amber-dim); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: var(--border);
  color: var(--text);
  white-space: nowrap;
}
.btn-secondary:hover    { background: #5a4530; }
.btn-secondary:disabled { opacity: .4; cursor: not-allowed; }

/* copy-url button (icon-only) */
#copy-url-btn {
  background: var(--border);
  border: none;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  padding: .5rem .75rem;
  transition: background .2s;
}
#copy-url-btn:hover { background: #5a4530; }

/* ── Download group ─────────────────────────────────────────────── */
.download-group { margin-top: auto; }

/* ── Preview panel internals ────────────────────────────────────── */
#placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: .95rem;
  padding: 2rem;
  text-align: center;
}

.error-text { color: var(--error); }

#preview-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
}

#preview-svg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 1rem;
}
#preview-svg svg { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* ── Loading spinner ────────────────────────────────────────────── */
#loading {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  color: var(--text-dim);
  font-size: .9rem;
  position: absolute;
  inset: 0;
  background: var(--surface);
  z-index: 10;
}

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

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  main { flex-direction: column; }
  .preview-panel { min-height: 280px; }
}
