* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2933;
  background-color: #f5f7fb;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  background: #ffffff;
  border-bottom: 1px solid #e1e4f0;
}

.site-header-inner {
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px;
}

.site-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-title-block {
  display: flex;
  flex-direction: column;
}

.site-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
}

.site-subtitle {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

.site-header-link {
  font-size: 13px;
  color: #2563eb;
  text-decoration: none;
  white-space: nowrap;
}

.site-header-link:hover {
  text-decoration: underline;
}

.main {
  flex: 1;
  width: 100%;
  margin: 16px auto 24px;
  padding: 0 24px;
}

.section {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.section-header {
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.section-desc {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

.section-templates {
  padding-bottom: 12px;
}

.template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.template-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.template-button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px;
  background-color: #ffffff;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.template-button-inner {
  min-width: 96px;
  height: 40px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
}

.template-caption {
  font-size: 11px;
  color: #4b5563;
}

.template-button:hover {
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
  transform: translateY(-1px);
}

.template-button--active {
  border-color: #2563eb;
}

.section-editor {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr);
  gap: 16px;
}

.editor-left {
  border-right: 1px solid #eef0f7;
  padding-right: 16px;
}

.editor-right {
  padding-left: 8px;
}

.control-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px 12px;
}

.fieldset legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

.field {
  margin-bottom: 10px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: inline-block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #374151;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-row > .field-label {
  min-width: 72px;
  white-space: nowrap;
}

.field-row--split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.field-row--wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.field-input-with-counter {
  display: flex;
  align-items: center;
  gap: 6px;
}

.char-counter {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

input[type="range"] {
  width: 100%;
}

.field-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #4b5563;
}

.field-color {
  border-top: 1px dashed #e5e7eb;
  padding-top: 8px;
}

.field-color:first-of-type {
  border-top: none;
  padding-top: 0;
}

.field-color-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-color-main input[type="color"] {
  width: 32px;
  height: 24px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  background: none;
}

.color-hex {
  max-width: 90px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.preview-card {
  background: #f9fafb;
  border-radius: 8px;
  padding: 10px 12px 12px;
  border: 1px solid #e5e7eb;
  margin-bottom: 10px;
}

.preview-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.preview-area {
  background: #e5e7eb;
  border-radius: 6px;
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo-preview-wrapper {
  max-width: 100%;
  overflow: auto;
}

.logo-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 320px;
  height: 180px;
  padding: 20px 36px;
  border-radius: 8px;
  background-color: #000000;
  box-sizing: border-box;
}

.logo-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-line--bottom {
  margin-top: 6px;
}

.logo-text {
  font-size: 48px;
  font-weight: 500;
}

.logo-text--left {
  color: #ffffff;
  margin-right: 6px;
}

.logo-text--right {
  padding: 4px 8px;
  border-radius: 4px;
  background-color: #f59e0b;
  color: #000000;
}

.preview-meta {
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.export-card {
  background: #f9fafb;
  border-radius: 8px;
  padding: 10px 12px 12px;
  border: 1px solid #e5e7eb;
}

.preview-area--transparent {
  background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.export-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.size-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.size-btn {
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  background-color: #ffffff;
  font-size: 12px;
  cursor: pointer;
}

.size-btn--active {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.size-custom {
  margin-top: 6px;
  font-size: 12px;
  color: #4b5563;
}

.size-custom input[type="number"] {
  width: 70px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 6px 14px;
  border: 1px solid transparent;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-primary {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  width: 100%;
  font-weight: 600;
}

.btn-primary:hover {
  background-color: #1d4ed8;
}

.btn-subtle {
  background-color: #ffffff;
  border-color: #d1d5db;
  color: #374151;
}

.btn-subtle:hover {
  background-color: #f3f4f6;
}

.export-actions {
  margin-top: 10px;
}

.site-footer {
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  padding: 10px 0 16px;
}

#renderCanvas {
  display: none;
}

@media (max-width: 960px) {
  .section-editor {
    grid-template-columns: 1fr;
  }

  .editor-left {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid #eef0f7;
    padding-bottom: 12px;
    margin-bottom: 12px;
  }

  .editor-right {
    padding-left: 0;
  }
}
