* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: Arial, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: #f3f6fb;
  color: #172033;
}

button,
input,
select {
  font: inherit;
}

.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.page-header {
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0 0 7px;
  font-size: 32px;
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 0;
  color: #667085;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1fr) minmax(380px, 1.15fr);
  gap: 20px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: #ffffff;
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.07);
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 22px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

label {
  display: block;
  margin: 14px 0 7px;
  font-weight: 700;
}

input[type="url"],
input[type="text"],
select {
  width: 100%;
  min-width: 0;
  padding: 12px 13px;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  background: #ffffff;
  color: #172033;
}

input[type="range"] {
  width: 100%;
}

input[type="color"] {
  display: block;
  width: 100%;
  height: 44px;
  margin-top: 7px;
  padding: 4px;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  background: #ffffff;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

button {
  border: 0;
  border-radius: 12px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.input-row button {
  min-width: 78px;
  padding: 0 16px;
}

button:hover {
  filter: brightness(0.97);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary-button {
  background: #475467;
}

.status-box {
  margin-top: 16px;
  padding: 13px 14px;
  border-radius: 12px;
  background: #eef4ff;
  color: #1e3a8a;
}

#apiStatus[data-type="success"] {
  color: #166534;
}

#apiStatus[data-type="error"] {
  color: #b42318;
}

#apiStatus[data-type="loading"] {
  color: #1d4ed8;
}

.manual-source,
.site-info,
.editor-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #e4e7ec;
}

.site-info dl {
  margin: 0;
}

.site-info dl > div {
  margin-bottom: 13px;
}

.site-info dt {
  margin-bottom: 3px;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
}

.site-info dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

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

.empty-message {
  padding: 26px 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  color: #64748b;
  text-align: center;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.candidate-card {
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 14px;
  background: #ffffff;
  color: #172033;
  text-align: left;
  box-shadow: inset 0 0 0 1px #e4e7ec;
}

.candidate-card:hover {
  box-shadow: inset 0 0 0 1px #93c5fd;
}

.candidate-card.is-selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.candidate-card.is-broken {
  opacity: 0.58;
}

.candidate-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 5 / 3;
  padding: 14px;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-size: 18px 18px;
  background-position:
    0 0,
    0 9px,
    9px -9px,
    -9px 0;
}

.candidate-image {
  display: block;
  max-width: 100%;
  max-height: 132px;
  object-fit: contain;
}

.candidate-fallback {
  color: #98a2b3;
  font-size: 12px;
}

.candidate-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 12px 13px;
}

.candidate-content strong {
  font-size: 13px;
  line-height: 1.35;
}

.candidate-type {
  color: #667085;
  font-size: 11px;
}

.api-details {
  margin-top: 20px;
}

.api-details summary {
  cursor: pointer;
  color: #475467;
  font-weight: 700;
}

pre {
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: #101828;
  color: #e4e7ec;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-panel {
  position: sticky;
  top: 20px;
}

.canvas-shell {
  overflow: hidden;
  border-radius: 16px;
  background: #e2e8f0;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 3;
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: #667085;
  font-size: 12px;
}

.download-button {
  width: 100%;
  margin-top: 18px;
  padding: 14px 18px;
  background: #0f766e;
  font-size: 16px;
}

.helper-text {
  margin: 12px 0 0;
  color: #667085;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1180px) {
  .app-layout {
    grid-template-columns: minmax(320px, 0.9fr) minmax(380px, 1.1fr);
  }

  .preview-panel {
    position: static;
    grid-column: 1 / -1;
  }
}

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

  .preview-panel {
    grid-column: auto;
  }
}

@media (max-width: 500px) {
  .container {
    padding-inline: 12px;
  }

  .panel {
    padding: 18px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .input-row button {
    padding: 12px 16px;
  }

  .candidate-grid {
    grid-template-columns: 1fr;
  }
}