:root {
  --bg: #f1f3f9;
  --surface: #ffffff;
  --ink: #1a2233;
  --ink-soft: #5b6577;
  --line: #e4e7ee;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef0fe;
  --error: #c02626;
  --error-soft: #fdf2f2;
  --ok: #15803d;
  --warning: #a16207;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 32px rgb(23 32 68 / 0.08);
  --focus: 0 0 0 3px rgb(79 70 229 / 0.35);
}

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

[hidden] {
  display: none !important;
}

html {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 420px at 85% -80px, rgb(79 70 229 / 0.10), transparent 70%),
    radial-gradient(900px 380px at -10% 0%, rgb(14 165 233 / 0.08), transparent 70%),
    var(--bg);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Cabecera ----------------------------------------------------------- */

.site-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.2rem 1.25rem 1.4rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  flex: none;
  background:
    linear-gradient(var(--accent), var(--accent)) padding-box,
    linear-gradient(135deg, #6366f1, #0ea5e9) border-box;
  border: 1.5px solid transparent;
  position: relative;
  box-shadow: 0 8px 20px rgb(79 70 229 / 0.28);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  border-radius: 3px;
  background: #fff;
}

.brand-mark::before {
  inset: 9px auto auto 9px;
  width: 12px;
  height: 12px;
  box-shadow: 16px 0 0 #fff, 0 16px 0 #fff;
}

.brand-mark::after {
  right: 9px;
  bottom: 9px;
  width: 6px;
  height: 6px;
  box-shadow: -6px -6px 0 0 rgb(255 255 255 / 0.85);
}

.site-header h1 {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* --- Distribución --------------------------------------------------------- */

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 1.5rem;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.preview-card {
  position: sticky;
  top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.preview-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

/* --- Selector de tipo ----------------------------------------------------- */

.type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
}

.type-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-pill span {
  display: inline-block;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7f8fc;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.type-pill:hover span {
  border-color: #c9cede;
}

.type-pill input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgb(79 70 229 / 0.30);
}

.type-pill input:focus-visible + span {
  box-shadow: var(--focus);
}

/* --- Formularios ----------------------------------------------------------- */

fieldset {
  border: 0;
  margin: 0 0 1.35rem;
  padding: 0;
}

legend {
  font-weight: 650;
  font-size: 1rem;
  margin-bottom: 0.8rem;
  padding: 0;
}

.field {
  margin-bottom: 0.85rem;
  min-width: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 0.85rem;
}

.field label {
  display: block;
  font-size: 0.87rem;
  font-weight: 560;
  margin-bottom: 0.3rem;
  color: var(--ink);
}

.field .optional {
  font-weight: 400;
  color: var(--ink-soft);
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.field-inline label {
  margin: 0;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="tel"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  font: inherit;
  font-size: 0.93rem;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

input[type="text"]:hover,
input[type="url"]:hover,
input[type="email"]:hover,
input[type="tel"]:hover,
input[type="datetime-local"]:hover,
textarea:hover,
select:hover {
  border-color: #c9cede;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

textarea {
  resize: vertical;
  min-height: 3.2em;
}

[aria-invalid="true"] {
  border-color: var(--error) !important;
  background: var(--error-soft);
}

.field-error {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--error);
}

.form-note {
  margin: -0.25rem 0 0.85rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

input[type="color"] {
  width: 100%;
  height: 2.4rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  cursor: pointer;
}

input[type="file"] {
  font-size: 0.85rem;
  color: var(--ink-soft);
  max-width: 100%;
}

input[type="file"]::file-selector-button {
  margin-right: 0.6rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* --- Panel de estilo ------------------------------------------------------- */

.style-panel {
  border-top: 1px solid var(--line);
  padding-top: 1.2rem;
}

.style-panel h3 {
  margin: 0 0 0.9rem;
  font-size: 1rem;
}

.presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.preset {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8f9fd;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 560;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.preset:hover {
  border-color: #c2c8dc;
  background: #fff;
}

.preset.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: 0 3px 10px rgb(79 70 229 / 0.16);
}

.preset-swatch {
  width: 1.35rem;
  height: 1.35rem;
  flex: none;
  border-radius: 5px;
  border: 1px solid rgb(0 0 0 / 0.12);
  background:
    linear-gradient(var(--swatch-fg), var(--swatch-fg)) 4px 4px / 6px 6px no-repeat,
    var(--swatch-bg);
}

.preset-swatch-round {
  border-radius: 50%;
}

.style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 0.85rem;
}

.logo-note {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.ghost-button {
  margin-top: 0.35rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: 0.83rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.ghost-button:hover {
  border-color: var(--error);
  color: var(--error);
}

/* --- Vista previa ----------------------------------------------------------- */

.preview-box {
  aspect-ratio: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    repeating-conic-gradient(#f4f5f9 0% 25%, #fdfdfe 0% 50%) 0 0 / 22px 22px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-box svg {
  width: 88%;
  height: 88%;
  display: block;
}

.status {
  margin: 0;
  font-size: 0.9rem;
  min-height: 1.4em;
  color: var(--ink-soft);
}

.status[data-kind="ok"] {
  color: var(--ok);
}

.status[data-kind="error"] {
  color: var(--error);
}

.warnings {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--warning);
}

.warnings:empty {
  display: none;
}

.download-actions {
  display: flex;
  gap: 0.65rem;
}

.primary-button,
.secondary-button {
  flex: 1;
  padding: 0.68rem 1rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 640;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 5px 16px rgb(79 70 229 / 0.30);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #f8f9fd;
  color: var(--ink);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.privacy-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
}

/* --- Adaptación a pantallas pequeñas ---------------------------------------- */

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

  .preview-card {
    position: static;
    order: -1;
  }

  .preview-box svg {
    width: 78%;
    height: 78%;
  }
}

@media (max-width: 560px) {
  .field-grid,
  .style-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 1.1rem;
  }

  .download-actions {
    flex-direction: column;
  }
}
