* {
  box-sizing: border-box;
}

@font-face {
  font-family: 'Hemi Head';
  src: url('/assets/hemi-head-bold-italic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-soft: #111827;
  --panel: rgba(31, 41, 55, 0.82);
  --panel-strong: #1f2937;
  --border: #374151;
  --border-soft: rgba(255, 255, 255, 0.08);
  --text: #f9fafb;
  --muted: #cbd5e1;
  --muted-2: #94a3b8;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --success: #86efac;
  --error: #fca5a5;
  --warning: #fcd34d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.18), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(6, 182, 212, 0.12), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 24px;
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.controls {
  align-self: start;
}

h1 {
  margin: 0 0 20px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
  letter-spacing: -0.04em;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row input[type="checkbox"] {
  width: auto;
  flex: 0 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

input,
select,
textarea,
button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
}

input,
select,
textarea {
  background: rgba(15, 23, 42, 0.86);
  border-color: var(--border-soft);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(139, 92, 246, 0.75);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.18);
  background: rgba(15, 23, 42, 0.96);
}

textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.35;
}

input[type="file"] {
  cursor: pointer;
}

input[type="range"] {
  padding-inline: 0;
  accent-color: var(--accent);
}

input[type="color"] {
  height: 44px;
  padding: 5px;
  cursor: pointer;
}

button {
  margin-top: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  color: white;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 30px rgba(139, 92, 246, 0.25);
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.secondary-button {
  width: auto;
  min-width: 110px;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  box-shadow: none;
}

.secondary-button:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.preview {
  position: sticky;
  top: 24px;
  display: grid;
  place-items: center;
  align-self: start;
  text-align: center;
}

canvas {
  width: min(512px, 100%);
  aspect-ratio: 1;
  background: transparent;
  border-radius: 28px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.status {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

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

.status.success {
  color: var(--success);
}

.hidden {
  display: none !important;
}

.hint,
.optional,
.text-counter {
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.45;
}

.text-counter {
  margin-top: -8px;
}

fieldset {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  margin: 0 0 18px;
  padding: 14px;
}

legend {
  padding: 0 8px;
  color: var(--text);
  font-size: 14px;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag-option {
  position: relative;
  width: auto;
  display: inline-flex;
  align-items: center;
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.tag-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.tag-option span {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--bg-soft), var(--bg-soft)) padding-box,
    var(--button-gradient) border-box;
  color: #e0f2fe;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  overflow: hidden;
  isolation: isolate;
  transition:
    color 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.tag-option span::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--button-gradient);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms ease;
}

.tag-option:hover span {
  box-shadow:
    0 0 0 3px rgba(6, 182, 212, 0.1),
    0 0 18px rgba(6, 182, 212, 0.18);
}

.tag-option input:checked + span {
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(6, 182, 212, 0.22);
}

.tag-option input:checked + span::before {
  transform: scaleX(1);
}

.tag-option input:focus-visible + span {
  outline: 2px solid rgba(6, 182, 212, 0.9);
  outline-offset: 3px;
}

.control-section {
  overflow: hidden;
  margin: 0 0 14px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: rgba(17, 24, 39, 0.64);
  transition: border-color 150ms ease, background 150ms ease;
}

.control-section:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.control-section summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 15px 16px;
  cursor: pointer;
  user-select: none;
  font-weight: 800;
  letter-spacing: 0.01em;
  list-style: none;
}

.control-section summary::-webkit-details-marker {
  display: none;
}

.control-section summary::after {
  content: '+';
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  transition: transform 150ms ease, background 150ms ease;
}

.control-section[open] summary::after {
  content: '−';
  background: rgba(139, 92, 246, 0.22);
  color: white;
}

.control-section[open] {
  background: rgba(17, 24, 39, 0.82);
}

.control-section[open] > :not(summary) {
  animation: sectionIn 180ms ease both;
}

@keyframes sectionIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.control-section > label,
.control-section > .grid,
.control-section > .hint,
.control-section > .text-counter,
.control-section > .row,
.control-section > .pack-fields,
.control-section > fieldset,
.control-section > .rules {
  margin-left: 16px;
  margin-right: 16px;
}

.control-section > label:first-of-type,
.control-section > .hint:first-of-type,
.control-section > .grid:first-of-type,
.control-section > .row:first-of-type,
.control-section > .pack-fields:first-of-type {
  margin-top: 16px;
}

.control-section > label:last-child,
.control-section > .hint:last-child,
.control-section > .grid:last-child,
.control-section > .row:last-child,
.control-section > .pack-fields:last-child {
  margin-bottom: 16px;
}

.section-summary {
  max-width: 150px;
  overflow: hidden;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: normal;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

.icon-name-field {
  margin: 18px 0 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(24, 34, 49, 0.82);
  border: 1px solid var(--border-soft);
}

.warning {
  margin: 0 16px 16px;
  padding: 12px 14px;
  border: 1px solid #f59e0b;
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.13);
  color: var(--warning);
  font-size: 13px;
  line-height: 1.45;
}

.rules {
  padding: 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid var(--border-soft);
}

.rules ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.compact-button {
  width: auto;
  margin: 0 16px 16px;
  padding: 9px 12px;
}

.adjustment-group,
.style-recolor-block {
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.48);
}

.adjustment-group label:last-child,
.style-recolor-block label:last-child {
  margin-bottom: 0;
}

.preset-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 10px;
  margin: 0 16px 16px;
}

.preset-color {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  min-height: 38px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  box-shadow: none;
  overflow: hidden;
}

.preset-color:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.preset-color.selected::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 9px;
  pointer-events: none;
}

.custom-color-group {
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.48);
}

.custom-color-group > strong {
  display: block;
  margin-bottom: 14px;
  color: var(--text);
  font-size: 14px;
}

.custom-color-group label:last-child {
  margin-bottom: 0;
}

.footer {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 0 32px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.footer a {
  color: var(--muted);
  text-decoration: none;
}

.footer-icon {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(31, 41, 55, 0.82);
  border: 1px solid var(--border-soft);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.footer-icon:hover {
  transform: translateY(-2px);
  background: rgba(39, 50, 68, 0.92);
  border-color: rgba(255, 255, 255, 0.18);
}

.footer-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.footer-icon-discord {
  color: #5865f2;
}

.footer-icon-trello {
  color: #0079bf;
}

.footer-icon-twitter {
  color: #ffffff;
}

.footer-icon-pack img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

.footer-credit {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.heart {
  color: #ef4444;
}

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

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

  .panel {
    padding: 18px;
    border-radius: 18px;
  }

  .footer {
    padding-inline: 20px;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 14px;
    gap: 14px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .control-section summary {
    grid-template-columns: 1fr auto;
  }

  .section-summary {
    grid-column: 1 / -1;
    max-width: none;
  }

  .footer-links {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

.inline-fieldset {
  display: grid;
  grid-template-columns: auto auto;
  gap: 10px 18px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
}

.inline-fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.inline-fieldset .row {
  margin: 0;
  color: var(--muted);
}

.inline-fieldset input[type="radio"] {
  width: auto;
  flex: 0 0 auto;
  accent-color: var(--accent);
}


/* Stable native controls: prevents visual flicker/glitch on checkbox and radio clicks. */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  border: 0;
  border-radius: initial;
  background: transparent;
  box-shadow: none;
  transition: none;
  transform: none;
  accent-color: var(--accent);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  box-shadow: none;
  outline: 2px solid rgba(139, 92, 246, 0.7);
  outline-offset: 3px;
}

.row input[type="checkbox"],
.inline-fieldset input[type="radio"] {
  flex: 0 0 auto;
  margin: 0;
}



/* Visual switches for option checkboxes. Native checkbox is kept for accessibility. */
.switch-row {
  width: 100%;
  cursor: pointer;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.switch-row input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  padding: 0;
  margin: -1px;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.switch-row .switch-track {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
  order: 2;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  transition: background 160ms ease, border-color 160ms ease;
}

.switch-row .switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: transform 160ms ease, background 160ms ease;
}

.switch-row input[type="checkbox"]:checked + .switch-track {
  border-color: rgba(139, 92, 246, 0.9);
  background: linear-gradient(135deg, var(--accent), #06b6d4);
}

.switch-row input[type="checkbox"]:checked + .switch-track::after {
  transform: translateX(20px);
  background: #ffffff;
}

.switch-row input[type="checkbox"]:focus-visible + .switch-track {
  outline: 2px solid rgba(139, 92, 246, 0.75);
  outline-offset: 3px;
}

.switch-row > span:last-child {
  flex: 1 1 auto;
}

.pack-fields .icon-name-field {
  margin: 18px 0 18px;
}

.rights-confirmation {
  margin-top: 22px;
}

/* UI polish: clean left-aligned switches and gradient tag pills. */
:root {
  --button-gradient: linear-gradient(135deg, var(--accent), #06b6d4);
  --button-gradient-soft: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(6, 182, 212, 0.18));
}

.switch-row {
  justify-content: flex-start;
  gap: 8px;
  padding-right: 8px;
}

.switch-row .switch-track {
  order: 0;
  margin-right: 4px;
}

.switch-row > span:last-child {
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
}

.status-switch-row .switch-track {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.42);
}

.status-switch-row input[type="checkbox"]:checked + .switch-track {
  background: var(--button-gradient);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Style/Colors grouping refinements. */
.style-group {
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.48);
}

.style-group > strong {
  display: block;
  margin-bottom: 14px;
  color: var(--text);
  font-size: 14px;
}

.style-group label:last-child {
  margin-bottom: 0;
}

.style-presets-group .preset-colors {
  margin: 14px 0 0;
}

.custom-color-group {
  margin-top: 0;
}

.section-separator {
  height: 1px;
  margin: 4px 16px 18px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
}
