:root {
  --bg:       #0B1120;
  --surface:  #161F30;
  --surface2: #1E2A3F;
  --border:   #243047;
  --text:     #F1F5F9;
  --muted:    #94A3B8;
  --blue:     #2dd4bf;
  --blue2:    #5eead4;
  --btn-ink:  #04201a;
  --red:      #e05555;
  --radius:   8px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
}

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 16px 56px;
}

/* ---------- Header ---------- */
.hdr {
  text-align: center;
  margin-bottom: 36px;
}

.hdr {
  position: relative;
}

.hdr h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--blue);
}

.home-link {
  position: absolute;
  top: 6px;
  right: 0;
  font-family: Consolas, Menlo, monospace;
  font-size: 0.8rem;
  color: var(--blue);
  text-decoration: none;
  opacity: 0.75;
  transition: opacity 0.2s;
}

.home-link:hover,
.home-link:focus-visible {
  opacity: 1;
}

.subtitle {
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.9rem;
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

@media (min-width: 700px) {
  .layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 48px;
  }
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  flex-direction: row;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-hint {
  font-size: 12px;
  color: var(--blue);
  word-break: break-all;
  min-height: 16px;
}

.field-error {
  font-size: 12px;
  color: var(--red);
}

/* ---------- Inputs ---------- */
select,
input[type="text"],
input[type="tel"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
  appearance: auto;
}

select:focus,
input[type="text"]:focus,
input[type="tel"]:focus {
  border-color: var(--blue);
}

input[type="file"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  cursor: pointer;
}

input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  display: block;
}

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

/* ---------- Pozadí (fieldset) ---------- */
.bg-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bg-fieldset legend {
  padding: 0 6px;
}

.radio-row {
  display: flex;
  gap: 24px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.bg-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Checkbox ---------- */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  margin-top: 6px;
}

/* ---------- Tlačítka ---------- */
.btn-primary {
  background: var(--blue);
  color: var(--btn-ink);
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}

.btn-primary:hover {
  background: var(--blue2);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.download-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.btn-download {
  display: block;
  width: 100%;
  text-align: center;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.btn-download:hover {
  border-color: var(--blue);
  background: var(--surface);
}

.dim-note {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Preview ---------- */
.preview-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.preview-label {
  align-self: flex-start;
}

.preview-frame {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 9 / 16;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface2);
}

@media (min-width: 700px) {
  .preview-frame {
    max-width: 260px;
  }
}

#preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Off-screen canvas ---------- */
#wallpaper-canvas {
  position: absolute;
  left: -99999px;
  top: 0;
  pointer-events: none;
}

/* ---------- Utility ---------- */
.hidden {
  display: none !important;
}
