body {
  font-family: Arial, sans-serif;
  text-align: center;
  background: #111;
  color: #eee;
  padding: 15px;
  margin: 0;
  font-size: 16px;
  -webkit-user-select: none;
  user-select: none;
}

h2 {
  margin-top: 8px;
  margin-bottom: 12px;
  font-size: 24px;
}

p {
  margin: 8px 0;
  font-size: 16px;
}

/* 字数警告样式 */
.char-warn {
  background: #ff4d4f !important;
  color: white;
  font-weight: bold;
}

.char-ok {
  background: #0f5f0f !important;
  color: white !important;
}

#output {
  #font-size: 20px;
  #line-height: 20px;
  white-space: pre;
  font-family: monospace;
  #letter-spacing: 4px;
  margin-top: 20px;
  text-align: left;
}

#output-div {
  display: inline-block;
  text-align: center;
  border: 1px solid #555;
  padding: 10px;
  background: #222;
  margin-top: 15px;
}

input {
  font-size: 16px;
  padding: 10px 8px;
  margin: 8px 4px;
  border: 1px solid #666;
  border-radius: 4px;
  background: #222;
  color: #eee;
  box-sizing: border-box;
  min-height: 44px;
}

input[type="text"] {
  width: 90vw;
  max-width: 280px;
}

input[type="number"] {
  width: 80px;
}

input[type="range"] {
  width: 70vw;
  # max-width: 300px;
}

button {
  padding: 10px 16px;
  font-size: 16px;
  background: #333;
  color: #fff;
  border: 1px solid #555;
  cursor: pointer;
  border-radius: 4px;
  min-height: 44px;
  min-width: 44px;
  margin: 4px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

button:hover {
  background: #444;
}

button:active {
  background: #555;
}

select {
  font-size: 16px;
  padding: 10px 8px;
  margin: 8px 4px;
  border: 1px solid #666;
  border-radius: 4px;
  background: #222;
  color: #eee;
  min-height: 44px;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.slider-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 15px auto;
  max-width: 90vw;
  padding: 0 10px;
  box-sizing: border-box;
  flex-wrap: wrap;
}

.slider-container label {
  margin-right: 10px;
  min-width: 120px;
  text-align: right;
  font-size: 14px;
}

.slider-container input[type="range"] {
  flex-grow: 1;
  min-width: 100px;
}

.slider-container .slider-value {
  min-width: 30px;
  margin-left: 10px;
  text-align: left;
}

/* ===== 移动端响应式设计 ===== */

/* 小屏幕设备（手机竖屏：宽度 < 600px） */
@media (max-width: 599px) {
  body {
    padding: 10px;
    font-size: 15px;
  }

  h2 {
    font-size: 20px;
    margin: 6px 0;
  }

  p {
    font-size: 14px;
    margin: 6px 0;
  }

  input[type="text"] {
    width: 100%;
    max-width: 100%;
  }

  input {
    width: auto;
    max-width: 100%;
  }

  button {
    padding: 12px 14px;
    font-size: 15px;
    margin: 6px 2px;
    display: inline-block;
  }

  select {
    width: 100%;
    max-width: 100%;
    margin: 10px 0;
  }

  .slider-container {
    flex-direction: column;
    align-items: stretch;
    margin: 12px auto;
    max-width: 100%;
  }

  .slider-container label {
    text-align: center;
    min-width: auto;
    margin-right: 0;
    margin-bottom: 8px;
    font-size: 13px;
  }

  .slider-container input[type="range"] {
    width: 100%;
    margin: 0;
  }

  .slider-container .slider-value {
    margin-left: 0;
    text-align: center;
    margin-top: 6px;
  }

  #output {
    font-size: 12px;
    line-height: 1.4;
    padding: 8px;
    overflow-x: auto;
    word-break: break-all;
  }

  #output-div {
    max-width: 100%;
    padding: 8px;
    margin-top: 12px;
  }

  /* 移动端友好的复选框与标签 */
  label {
    display: block;
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.6;
  }

  input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    vertical-align: middle;
  }

  /* 信息标签更大 */
  #charCount {
    display: block;
    margin: 8px 0;
    padding: 6px 8px !important;
    font-size: 14px;
  }

  #copyTip {
    display: block;
    margin-top: 8px;
    font-size: 14px;
  }

  /* 移除文本选择以改进触摸体验 */
  span, p, h2, label {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* 中等屏幕设备（手机横屏或小平板：600px - 900px） */
@media (min-width: 600px) and (max-width: 900px) {
  body {
    padding: 15px;
    font-size: 15px;
  }

  input[type="text"] {
    width: 250px;
  }

  #output {
    font-size: 13px;
  }
}

/* 大屏幕设备（平板或桌面：> 900px） */
@media (min-width: 901px) {
  body {
    padding: 20px;
    font-size: 16px;
  }

  input[type="text"] {
    width: 280px;
  }

  #output {
    font-size: 14px;
  }
}

/* 触摸设备通用优化 */
@media (hover: none) and (pointer: coarse) {
  button:active {
    background: #555;
    transform: scale(0.98);
  }

  input, select, button {
    border-radius: 6px;
  }
}

/* 编辑器按钮与模态样式 */
.icon-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  padding: 4px;
  border-radius: 6px;
  background: rgba(0,0,0,0.4);
  border: 1px solid #444;
  color: #fff;
  font-size: 16px;
}

#editor-modal.hidden { display: none; }
#editor-modal { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; }
#editor-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
#editor-content { position: relative; z-index: 1210; width: min(92vw, 900px); max-height: 90vh; background: #0f0f10; border: 1px solid #333; border-radius: 8px; overflow: hidden; display:flex; flex-direction:column; }

#editor-toolbar { display:flex; align-items:center; gap:8px; padding:8px; background:#111; border-bottom:1px solid #222; }
.tool-btn { background:#222; color:#fff; border:1px solid #333; padding:8px 10px; border-radius:6px; cursor:pointer; font-size:16px; }
.tool-btn:hover { background:#333; }
.tool-btn.active { outline:2px solid #2b8; }
.tool-btn.primary { background:#196; }
.tool-sep { flex: 1 0 8px; }

#editor-canvas-wrapper { padding:12px; overflow:auto; flex:1 1 auto; display:flex; justify-content:center; align-items:center; }
#editor-canvas { background:#111; color: #fff; font-family: monospace; white-space:pre; line-height:1; outline:none; }

/* 每个单元格通过 span 控制大小与间距 */
.editor-cell { display:inline-block; width:20px; height:22px; text-align:center; vertical-align:middle; font-size:16px; line-height:20px; user-select:none; }
.editor-cell.bg { color:#333; opacity:0.9; }
.editor-cell.fg { color:#ffda55; }

/* 撤销按钮在禁用时的样式 */
.tool-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* 小屏模式调整编辑器 */
@media (max-width: 599px) {
  #editor-content { width: 96vw; }
  .editor-cell { width:18px; height:20px; font-size:14px; }
}

