:root { color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: #f4f4f5;
  color: #111;
  font: 15px/1.5 "PingFang SC", "Microsoft YaHei", sans-serif;
}
#editor { max-width: 720px; margin: 0 auto; padding: 32px 20px 48px; }
.top h1 { margin: 0 0 8px; font-size: 22px; font-weight: 650; }
.top p, .hint { margin: 0; color: #666; }
form { display: grid; gap: 16px; margin-top: 24px; }
form h2 { margin: 0; font-size: 15px; }
label, fieldset { display: grid; gap: 6px; }
fieldset { border: 1px solid #e5e5e5; border-radius: 8px; padding: 12px; background: #fff; }
legend { padding: 0 6px; }
input[type="text"], select {
  height: 40px; border: 1px solid #d4d4d8; border-radius: 6px; padding: 0 10px; background: #fff; font: inherit;
}
.file-row { display: flex; gap: 8px; align-items: center; }
.drop { flex: 1; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.drop {
  position: relative;
  border: 1px dashed #a1a1aa; border-radius: 8px; padding: 18px; background: #fff;
  text-align: center; cursor: pointer; align-content: center;
}
.drop.over { border-color: #111; background: #fafafa; }
#file-label { overflow-wrap: anywhere; }
.drop input, .upload input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer;
}
.avatar-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.presets button, #them-custom, #me-preview {
  width: 40px; height: 40px; border-radius: 4px; padding: 0;
}
.presets button, #them-custom { border: 2px solid transparent; background: #fff; }
.presets button[aria-pressed="true"], #them-custom[aria-pressed="true"] { border-color: #111; }
.presets button, #them-custom { overflow: hidden; }
.presets img, #them-custom img {
  display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 2px;
}
#me-preview { display: block; width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.upload {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 12px; border: 1px solid #d4d4d8; border-radius: 6px;
  background: #fff; cursor: pointer; width: fit-content;
}
.msg-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#selected-count { margin-left: auto; color: #666; font-size: 13px; }
#messages {
  list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow: auto;
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px;
}
#messages:empty { margin: 0; max-height: none; overflow: visible; background: none; border: 0; }
#messages li { border-bottom: 1px solid #f4f4f5; }
#messages li:last-child { border-bottom: 0; }
#messages li label {
  display: flex; gap: 8px; align-items: flex-start; width: 100%; padding: 8px 10px; cursor: pointer;
}
#messages input[type="checkbox"] { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: #111; }
.who-side {
  flex: none; max-width: 6em; color: #666; font-size: 12px; line-height: 18px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.snippet {
  flex: 1; min-width: 0; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
button {
  min-height: 40px; border: 1px solid #d4d4d8; border-radius: 6px; background: #fff;
  font: inherit; padding: 0 12px; cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
#preview, #save { background: #111; color: #fff; border-color: #111; }
#preview:disabled, #save:disabled { background: #e4e4e7; color: #52525b; border-color: #e4e4e7; }
.preview-sticky {
  position: sticky; bottom: 0; z-index: 2; background: #f4f4f5; padding: 12px 0 4px;
}
.preview-sticky #preview { width: 100%; }
.error { color: #b91c1c; margin: 0; }
.toast {
  position: fixed; z-index: 5; left: 50%; top: 16px; transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px)); margin: 0; padding: 10px 14px;
  border-radius: 8px; background: #111; color: #fff; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
}
button:focus-visible, select:focus-visible, input[type="text"]:focus-visible,
.drop:focus-within, .upload:focus-within {
  outline: 2px solid #111; outline-offset: 2px;
}
#preview-view { height: 100vh; display: flex; flex-direction: column; background: #e6e6e6; }
#preview-view[hidden] { display: none !important; }
body:not(.previewing) #preview-view { display: none; }
.preview-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid #e5e5e5;
}
.pager-group { display: flex; gap: 8px; align-items: center; }
.bar-spacer { flex: 1 1 auto; }
#status { color: #666; font-size: 13px; }
#status:empty { display: none; }
#status:not(:empty) { flex: 1 0 100%; }
.preview-scroll { flex: 1; overflow: auto; }
.stage.live header { position: sticky; top: 0; z-index: 2; }
@media (max-width: 640px) {
  .pair { grid-template-columns: 1fr; }
}
