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

body,
button {
  font-size: 1rem;
  line-height: 1.6;
  color: #000;
}

body {
  background: #fff;
  min-height: 100vh;
  padding: 2.5rem 1rem;
  max-width: 90rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

h1 {
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

#leftPanel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#rightPanel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 2rem;
}

#textInput.autoWidth {
  width: 100%;
  min-height: 5rem;
  padding: 0.75rem;
  border: 1px solid #e0e0e0;
  border-radius: 0.75rem;
  font-size: 1.25rem;
  font-family: monospace;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  position: relative;
}

.textInput-wrapper {
  position: relative;
}

.highlightOverlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  font-size: 1.25rem;
  font-family: monospace;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  pointer-events: none;
  color: transparent;
  background: transparent;
}

.highlight-char {
  color: red;
}

#textInput.autoWidth:focus {
  border-color: #000;
}

#textInput.autoWidth:empty::before {
  content: attr(placeholder);
  color: #999;
  pointer-events: none;
}


.config-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}


.config-item {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.config-item-label {
  font-size: 0.75rem;
  color: #666;
}

.config-item-content {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: 0.625rem;
  border: 1px solid #e0e0e0;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 1rem;
}

.radio-option:hover {
  border-color: #ccc;
}

.radio-option>input[type="radio"] {
  display: none;
}

.radio-option:has(> input[type="radio"]:checked) {
  background: #000;
  border-color: #000;
  color: #fff;
}

.radio-option>img {
  width: 1.25rem;
  height: 1.25rem;
  image-rendering: pixelated;
}

.char-symbol {
  font-family: monospace;
}

.custom-select {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid #e0e0e0;
  border-radius: 0.625rem;
  font-size: 1rem;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s;
}

.custom-select-trigger:hover {
  border-color: #ccc;
}

.custom-select.open>.custom-select-trigger {
  border-color: #000;
}

.custom-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  width: 100%;
  background: rgba(250, 250, 250, 0.85);
  -webkit-backdrop-filter: blur(1rem);
  backdrop-filter: blur(1rem);
  border: 1px solid #e0e0e0;
  border-radius: 0.625rem;
  padding: 0.25rem;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.custom-select.open>.custom-select-dropdown {
  display: block;
}

.custom-select-dropdown>.custom-select-option {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-option:hover {
  background: #f5f5f5;
}

.custom-select-option.active {
  background: #000;
  color: #fff;
}


.custom-select-dropdown>.custom-select-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-top: 0.25rem;
  border: 1px solid #e0e0e0;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  background: #fff;
}

.custom-select-input:focus {
  border-color: #000;
}

.btn-primary {
  width: 100%;
  padding: 0.5rem 0.875rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  background: #000;
  color: #fff;
  border: unset;
  border-radius: 0.625rem;
  cursor: pointer;
  transition: opacity 0.15s;
  box-sizing: border-box;
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-primary:active {
  opacity: 0.7;
}

#previewWrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#previewWrapper>div:first-child {
  font-size: 0.75rem;
  color: #666;
}

#canvasWrapper {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.previewCanvas {
  height: 4em;
  border: 1px solid #e0e0e0;
  border-radius: 0.5rem;
  image-rendering: pixelated;
  background: #fff;
}

#outputWrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.output-title {
  font-size: 0.75rem;
  color: #666;
}

#signsWrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sign {
  display: grid;
  grid-template-columns: fit-content(100%) fit-content(100%);
  border: 1px solid #e0e0e0;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #fff;
}

.sign>button:not(.lineCopyButton) {
  grid-column: 1 / -1;
  width: 100%;
  padding: 0.625rem;
  border: none;
  border-top: 1px solid #e0e0e0;
  background: #fff;
  color: #000;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
}

.sign>button:not(.lineCopyButton):hover {
  background: #f5f5f5;
}

.signLine {
  line-height: 1;
  margin: 0;
  padding: 0;
  -webkit-user-select: all;
  user-select: all;
  text-align: center;
  overflow: hidden;
  background: #fafafa;
  color: #000;
  white-space: pre;
  font-family: inherit;
  letter-spacing: 0;
  word-spacing: 0;
}

.lineCopyButton {
  width: 4rem;
  padding: 0;
  border: none;
  border-left: 1px solid #e0e0e0;
  background: #fff;
  color: #000;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lineCopyButton:hover {
  background: #f5f5f5;
}

.clipboard-helper {
  position: fixed;
}

#toastContainer {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0.5rem;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: rgba(100, 100, 100, 0.85);
  backdrop-filter: blur(1rem);
  -webkit-backdrop-filter: blur(1rem);
  color: #fff;
  padding: 0.625rem 1.25rem;
  border-radius: 0.625rem;
  font-size: 1rem;
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}

.toast.showing {
  opacity: 1;
  transform: translateY(0);
}

.toast.hiding {
  opacity: 0;
  transform: translateY(1rem);
}

.custom-char-section {
  display: none;
  margin-top: 0.75rem;
}

.custom-char-section.expanded {
  display: block;
}

.canvas-width-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

#patternWrapper input,
.canvas-width-row input,
.adjust-input {
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: 1px solid #e0e0e0;
  border-radius: 0.625rem;
  font-family: monospace;
  font-size: 1rem;
  line-height: 1.5;
  text-align: center;
  outline: none;
  background: #fff;
  box-sizing: border-box;
}

#patternWrapper input:focus,
.canvas-width-row input:focus,
.adjust-input:focus {
  border-color: #000;
}

#patternWrapper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

#patternWrapper>label,
.canvas-width-row label,
.adjust-param {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  background: #fafafa;
  border-radius: 0.5rem;
  text-align: center;
}

.input-title {
  font-family: monospace;
  font-size: 0.75rem;
  color: #999;
}

.adjust-param--plain {
  background: transparent;
}

@media (min-width: 40rem) {
  body {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2rem;
  }

  h1 {
    width: 100%;
  }

  #leftPanel {
    flex: 1;
    min-width: 15rem;
  }

  #rightPanel {
    flex: 1;
    min-width: 15rem;
    margin-top: 0;
  }
}

@media (max-width: 40rem) {
  body {
    padding: 1.25rem 1rem;
    gap: 1rem;
  }

  h1 {
    font-size: 1rem;
    margin-bottom: 1.75rem;
  }

  #patternWrapper,
  .canvas-width-row,
  .adjust-params {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== 微调面板 ===== */
#adjustPanel {
  margin-top: 0;
}

.adjust-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0 0 0.75rem 0;
}

.adjust-params {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.adjust-btn {
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: 1px solid transparent;
  border-radius: 0.625rem;
  background: #000;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  transition: opacity 0.15s;
  box-sizing: border-box;
}

.adjust-btn:hover {
  opacity: 0.85;
}

.adjust-toggle {
  font-size: 0.75rem;
  color: #666;
  text-decoration: underline;
  cursor: pointer;
  user-select: none;
  width: fit-content;
  transition: color 0.15s;
}

.adjust-toggle:hover {
  color: #000;
}