:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #0b1014;
  color: #e7edf0;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #0b1014;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #0b1014;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid #34424b;
  border-radius: 5px;
  background: #192229;
  color: #edf3f5;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

button:hover:not(:disabled) {
  border-color: #73838d;
  background: #26343c;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid #7fd3b1;
  outline-offset: 2px;
}

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

h1,
h2,
p {
  margin: 0;
}

.app-header {
  align-items: center;
  border-bottom: 1px solid #253139;
  display: flex;
  justify-content: space-between;
  min-height: 66px;
  padding: 0 30px;
}

.brand {
  align-items: center;
  color: inherit;
  display: inline-flex;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  align-items: flex-end;
  background: #18252a;
  border: 1px solid #3b6659;
  border-radius: 4px;
  display: flex;
  gap: 2px;
  height: 25px;
  justify-content: center;
  padding: 5px;
  width: 25px;
}

.brand-mark i {
  background: #7ed5ae;
  display: block;
  height: 8px;
  width: 3px;
}

.brand-mark i:nth-child(2) {
  height: 13px;
  background: #9bd6c4;
}

.brand-mark i:nth-child(3) {
  height: 17px;
  background: #d8b56e;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-kicker,
.section-label {
  color: #81919a;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.brand-copy strong {
  color: #eef4f3;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
}

.header-status {
  align-items: center;
  color: #8999a2;
  display: flex;
  font-size: 11px;
  gap: 7px;
  white-space: nowrap;
}

.header-status b {
  border-left: 1px solid #35424a;
  color: #c1d4cb;
  font-size: 11px;
  font-weight: 650;
  margin-left: 5px;
  padding-left: 10px;
}

.community-contact {
  border-left: 1px solid #35424a;
  color: #9ed9be;
  margin-left: 5px;
  padding-left: 10px;
  text-decoration: none;
}

.community-contact:hover {
  color: #c1f0d7;
}

.status-pip,
.status-dot {
  border-radius: 50%;
  display: inline-block;
}

.status-pip {
  background: #7bd4a9;
  box-shadow: 0 0 0 3px rgba(123, 212, 169, 0.1);
  height: 6px;
  width: 6px;
}

.app-shell {
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1500px;
  min-height: calc(100vh - 66px);
  padding: 26px 30px 34px;
}

.control-rail {
  min-width: 0;
}

.control-section {
  border-bottom: 1px solid #253139;
  padding: 0 0 23px;
}

.control-section + .control-section {
  padding-top: 23px;
}

.section-heading {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.section-number,
.summary-mark {
  color: #71cba2;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.section-heading h1,
.section-heading h2 {
  color: #edf3f4;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
}

.section-label {
  display: block;
  margin-top: 3px;
}

/* The helper tools sit in the blank space to the right of a section title.
   On narrow rails they wrap onto their own right-aligned line instead of
   squeezing the title. */
.editor-heading {
  column-gap: 8px;
  flex-wrap: wrap;
  position: relative;
  row-gap: 9px;
}

.section-heading-text {
  min-width: 0;
}

/* Scoped so these win against the later .helper-tools / .helper-tool rules
   regardless of source order. */
.editor-heading .helper-tools-inline {
  gap: 6px;
  grid-template-columns: repeat(2, auto);
  margin-left: auto;
  position: static;
}

.editor-heading .helper-tools-inline .helper-tool {
  position: static;
}

.editor-heading .helper-tools-inline .helper-tool summary {
  gap: 5px;
  padding: 0 7px;
}

.editor-heading .helper-tools-inline .helper-summary-title {
  gap: 5px;
}

.editor-heading .helper-tools-inline .helper-summary-icon {
  min-width: 21px;
  height: 17px;
  width: 21px;
}

/* Anchored to the heading, not to the button, so the popup can be as wide as
   the rail allows and still sit flush with its right edge. */
.editor-heading .color-tool .helper-tool-body,
.editor-heading .json-tool .helper-tool-body {
  left: auto;
  right: 0;
  top: calc(100% + 6px);
  transform: none;
  width: min(340px, 100%);
}

.editor-frame {
  background: #11191f;
  border: 1px solid #2a3942;
  border-radius: 7px;
  overflow: hidden;
}

.editor-frame:has(textarea[aria-invalid="true"]) {
  border-color: #e28383;
  box-shadow: 0 0 0 2px rgba(226, 131, 131, 0.1);
}

.editor-frame > label {
  border-bottom: 1px solid #253139;
  color: #aebdc2;
  display: block;
  font-size: 11px;
  margin: 0;
  padding: 10px 12px;
}

textarea,
input[type="text"],
input[type="number"] {
  appearance: none;
  background: #0b1115;
  border: 1px solid #35454e;
  border-radius: 5px;
  color: #edf4f4;
  min-width: 0;
  outline: none;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  border: 0;
  border-radius: 0;
  display: block;
  font-family: "Cascadia Code", Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
  line-height: 1.55;
  min-height: 330px;
  padding: 13px;
  resize: vertical;
  tab-size: 2;
}

.input-editor {
  min-height: 330px;
  position: relative;
}

.input-editor > textarea {
  background: #0b1115;
  position: relative;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  z-index: 1;
}

.input-highlight {
  background: transparent;
  box-sizing: border-box;
  color: transparent;
  font-family: "Cascadia Code", Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
  inset: 0;
  line-height: 1.55;
  margin: 0;
  overflow: hidden;
  padding: 13px;
  pointer-events: none;
  position: absolute;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  z-index: 2;
  /* The textarea does not inherit :root's optimizeLegibility (form controls
     resolve text-rendering to auto), so without this the two layers can lay
     text out differently and the red error mark drifts off its characters.
     Explicitly pin every metric-affecting font feature to match. */
  text-rendering: auto;
  font-kerning: none;
  font-variant-ligatures: none;
}

.input-highlight mark {
  background: rgba(226, 87, 87, 0.34);
  border-bottom: 1px solid #f18484;
  color: transparent;
  padding: 0;
}

textarea:focus,
input:focus {
  border-color: #72cda6;
  box-shadow: 0 0 0 2px rgba(114, 205, 166, 0.12);
}

textarea:focus {
  box-shadow: inset 0 0 0 1px #72cda6;
}

textarea[aria-invalid="true"] {
  box-shadow: inset 0 0 0 1px #e28383;
}

textarea::selection,
input::selection {
  background: #315b53;
  color: #ffffff;
}

textarea::placeholder,
input::placeholder {
  color: #62727b;
}

.editor-footer {
  align-items: center;
  border-top: 1px solid #253139;
  color: #71818a;
  display: flex;
  font-size: 10px;
  justify-content: space-between;
  padding: 8px 12px;
}

kbd {
  border: 1px solid #3a4a52;
  border-radius: 3px;
  color: #a7c8ba;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  line-height: 1;
  padding: 3px 5px;
}

.input-error {
  border-top: 1px solid rgba(226, 131, 131, 0.25);
  color: #f0a4a4;
  font-size: 11px;
  line-height: 1.5;
  margin: 0;
  padding: 9px 12px 10px;
}

.simulator-tool {
  min-width: 0;
}

.simulator-tool summary {
  align-items: center;
  color: #e4ecee;
  cursor: pointer;
  display: flex;
  font-size: 14px;
  font-weight: 650;
  justify-content: space-between;
  list-style: none;
  user-select: none;
}

.simulator-summary-actions {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  min-width: 0;
}

.mode-button {
  border-color: #536a61;
  color: #b7e3ca;
  font-size: 10px;
  font-weight: 600;
  padding: 5px 8px;
  white-space: nowrap;
}

.mode-button[aria-pressed="true"] {
  background: #315b4a;
  border-color: #79d2aa;
  color: #e5fff0;
}

.simulator-tool summary::-webkit-details-marker {
  display: none;
}

.summary-title {
  align-items: center;
  display: inline-flex;
  gap: 10px;
}

.summary-arrow {
  color: #7e9098;
  font-size: 18px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 140ms ease;
}

.simulator-tool:not([open]) .summary-arrow {
  transform: rotate(-90deg);
}

.simulator-tool[open] summary {
  margin-bottom: 15px;
}

.simulator-tool[data-mode="advanced"] .advanced-hide {
  display: none;
}

/* 高级模式下玩家 tag 与计分板被隐藏，只剩玩家名称：让字段容器变单列，
   名称框整行拉伸，与下方高级功能框（timeline-panel）左右边缘对齐，
   避免名称右侧空出一列。 */
.simulator-tool[data-mode="advanced"] .simulator-fields {
  grid-template-columns: minmax(0, 1fr);
}

.timeline-panel {
  background: #11191f;
  border: 1px solid #496356;
  border-radius: 6px;
  /* 玩家名称 之后紧接着面板，没有间距时两个圆角框的边线会粘在一起像叠在一起 */
  margin-top: 16px;
  padding: 12px;
}

.timeline-warning {
  border-left: 2px solid #d6b267;
  color: #ddc891;
  display: grid;
  font-size: 10px;
  gap: 3px;
  line-height: 1.45;
  margin-bottom: 13px;
  padding-left: 9px;
}

.timeline-warning strong {
  color: #f0d99e;
  font-size: 11px;
  font-weight: 650;
}

.timeline-label {
  color: #b5c5c8;
  display: block;
  font-size: 11px;
  margin-bottom: 6px;
}

.timeline-input {
  border: 1px solid #40534b;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.55;
  min-height: 174px;
  padding: 10px;
  resize: vertical;
}

.timeline-input:focus {
  border-color: #79d2aa;
  box-shadow: inset 0 0 0 1px #79d2aa;
}

.timeline-input[aria-invalid="true"] {
  border-color: #e28383;
  box-shadow: inset 0 0 0 1px #e28383;
}

.timeline-error {
  color: #f0a4a4;
  font-size: 10px;
  line-height: 1.45;
  margin-top: 8px;
}

.timeline-meta {
  color: #7e9197;
  display: flex;
  font-size: 10px;
  gap: 8px;
  justify-content: space-between;
  line-height: 1.35;
  margin-top: 8px;
}

/* The hint on the left is long; without this it squeezes the frame counter into
   two lines ("未生成" / "帧"). Let the hint wrap instead. */
.timeline-meta > span:last-child {
  flex: none;
  white-space: nowrap;
}

.timeline-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 12px;
}

.timeline-actions .action-button {
  min-height: 36px;
}

.simulator-fields {
  display: grid;
  gap: 11px;
  /* 玩家名称放短名字够用即可；玩家 tag 可能很长，占满剩余宽度 */
  grid-template-columns: 132px minmax(0, 1fr);
}

.simulator-fields .field:first-child {
  grid-column: 1;
}

/* 按语义定位，不再用 :nth-child 数位置 —— 否则以后增删字段又会把某一列挤歪 */
.simulator-fields .field-wide {
  grid-column: 2;
}

.field {
  min-width: 0;
}

.field label {
  color: #91a2a9;
  display: block;
  font-size: 11px;
  margin: 0 0 6px;
}

.field input {
  font-size: 12px;
  height: 36px;
}

.score-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-top: 17px;
}

.score-heading > span {
  color: #9cabb0;
  font-size: 11px;
  font-weight: 600;
}

.text-button {
  color: #9ed9be;
  font-size: 11px;
  padding: 5px 8px;
}

.text-button span {
  font-size: 15px;
  line-height: 0;
  vertical-align: -1px;
}

.score-table-wrap {
  border: 1px solid #2a3942;
  border-radius: 5px;
  margin-top: 9px;
  max-height: 205px;
  overflow: auto;
}

#score-table {
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
  width: 100%;
}

#score-table th,
#score-table td {
  border-bottom: 1px solid #253139;
  padding: 6px 5px;
  text-align: left;
}

#score-table tr:last-child td {
  border-bottom: 0;
}

#score-table th {
  background: #151e24;
  color: #819198;
  font-size: 10px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

#score-table th:nth-child(1) {
  width: 27%;
}

#score-table th:nth-child(2) {
  width: 30%;
}

#score-table th:nth-child(3) {
  width: 29%;
}

#score-table th:nth-child(4) {
  width: 14%;
}

#score-table input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #dce8e8;
  font-size: 11px;
  height: 27px;
  min-width: 0;
  padding: 4px 5px;
  width: 100%;
}

#score-table input:focus {
  background: #0b1115;
  border-color: #72cda6;
  box-shadow: none;
  outline: none;
}

#score-table .delete-score {
  align-items: center;
  background: transparent;
  border: 0;
  color: #87979d;
  display: flex;
  font-size: 16px;
  height: 27px;
  justify-content: center;
  padding: 0;
  width: 100%;
}

#score-table .delete-score:hover:not(:disabled) {
  background: rgba(226, 131, 131, 0.12);
  color: #ef9b9b;
}

/* 分数列：输入框 + 右侧一对上下箭头 */
.score-value {
  align-items: stretch;
  display: flex;
  gap: 3px;
  min-width: 0;
}

.score-value > input {
  flex: 1 1 auto;
  min-width: 0;
}

.score-stepper {
  display: grid;
  flex: 0 0 auto;
  gap: 1px;
  grid-template-rows: 1fr 1fr;
  width: 22px;
}

#score-table .score-step {
  align-items: center;
  background: #1b252c;
  border: 1px solid #34424b;
  border-radius: 3px;
  color: #9fb0b5;
  display: flex;
  font-size: 9px;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

#score-table .score-step:hover:not(:disabled) {
  background: #26343c;
  border-color: #79d2aa;
  color: #cdeadb;
}

#score-table .score-step:active:not(:disabled) {
  background: #315b4a;
  border-color: #79d2aa;
  color: #e5fff0;
}

.helper-tools {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
  min-width: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.helper-tool {
  background: #11191f;
  border: 1px solid #2a3942;
  border-radius: 5px;
  min-width: 0;
  overflow: visible;
  position: relative;
}

.background-tool {
  align-items: center;
  color: #e4ecee;
  cursor: pointer;
  display: flex;
  font-size: 11px;
  font-weight: 650;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 9px;
  user-select: none;
}

.background-tool:hover {
  background: #18252a;
  border-color: #73838d;
}

.background-tool:focus-visible {
  outline: 2px solid #7fd3b1;
  outline-offset: 2px;
}

.helper-tool summary {
  align-items: center;
  color: #e4ecee;
  cursor: pointer;
  display: flex;
  font-size: 11px;
  font-weight: 650;
  justify-content: space-between;
  list-style: none;
  min-height: 36px;
  padding: 0 9px;
  user-select: none;
}

.helper-tool summary::-webkit-details-marker {
  display: none;
}

.helper-tool[open] summary {
  border-bottom: 1px solid #253139;
}

.helper-tool[open] {
  z-index: 10;
}

.helper-tool:not([open]) .summary-arrow {
  transform: rotate(-90deg);
}

.helper-summary-title {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.helper-summary-icon {
  align-items: center;
  background: #1d332b;
  border: 1px solid #477360;
  border-radius: 3px;
  color: #a7e2c3;
  display: inline-flex;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  height: 19px;
  justify-content: center;
  line-height: 1;
  width: 24px;
}

.background-summary-swatch {
  background: #0a0e13;
  border-color: #64727a;
}

.background-picker-input {
  height: 1px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.helper-tool-body {
  background: #11191f;
  border: 1px solid #2a3942;
  border-radius: 5px;
  box-shadow: 0 14px 28px rgba(5, 10, 13, 0.42);
  left: 0;
  padding: 9px;
  position: absolute;
  top: calc(100% + 6px);
  z-index: 20;
}

.color-tool .helper-tool-body {
  left: 50%;
  transform: translateX(-50%);
  width: min(370px, 76vw);
}

.json-tool .helper-tool-body {
  left: auto;
  right: 0;
  width: min(315px, 76vw);
}

.helper-hint {
  color: #809097;
  font-size: 10px;
  line-height: 1.3;
  margin: 0 0 7px;
}

.helper-hint[data-type="ok"] {
  color: #8ed5ae;
}

.helper-hint[data-type="error"] {
  color: #e28383;
}

.color-code-grid {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
}

.color-chip {
  align-items: center;
  background: #192229;
  border: 1px solid #34424b;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 4px 2px;
}

.color-chip:hover:not(:disabled) {
  border-color: #79d2aa;
  background: #26343c;
}

.color-chip-preview {
  background: var(--chip-color);
  border-radius: 3px;
  color: var(--chip-ink);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden;
  padding: 1px 2px;
  text-align: center;
  width: 100%;
}

.color-chip code {
  color: #bac8cc;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  line-height: 1.1;
}

.color-chip-format .color-chip-preview {
  background: #26343c;
  border: 1px dashed #607078;
  color: #e2ebec;
}

.color-chip-k .color-chip-preview {
  letter-spacing: 2px;
  text-shadow: 1px 0 currentColor, -1px 0 currentColor;
}

.color-chip-l .color-chip-preview {
  font-weight: 700;
}

.color-chip-o .color-chip-preview {
  font-style: italic;
}

.color-chip-r .color-chip-preview {
  text-decoration: line-through;
}

.json-component-grid {
  display: grid;
  gap: 5px;
}

.json-chip {
  align-items: center;
  background: #192229;
  border: 1px solid #34424b;
  border-radius: 4px;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 5px 7px;
  text-align: left;
}

.json-chip:hover:not(:disabled) {
  border-color: #79d2aa;
  background: #26343c;
}

.json-chip-name {
  color: #9ed9be;
  font-size: 10px;
  font-weight: 650;
}

.json-chip code {
  color: #b5c3c7;
  display: block;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.action-button {
  align-items: center;
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  justify-content: center;
  min-height: 38px;
  padding: 8px 9px;
  white-space: nowrap;
}

.action-button > span {
  color: #9db2b8;
  font-size: 13px;
}

.primary {
  background: #79d2aa;
  border-color: #79d2aa;
  color: #0c1914;
  font-weight: 700;
}

.primary > span {
  color: #163324;
}

.primary:hover:not(:disabled) {
  background: #9ae0bd;
  border-color: #9ae0bd;
}

.status-line {
  align-items: center;
  display: grid;
  gap: 0 8px;
  grid-template-columns: 7px minmax(0, 1fr);
  margin-top: 13px;
  min-height: 20px;
}

.status-dot {
  background: #76868d;
  height: 7px;
  width: 7px;
}

.status-line:has(#status[data-type="ok"]) .status-dot {
  background: #79d2aa;
}

.status-line:has(#status[data-type="busy"]) .status-dot {
  background: #d6b267;
}

.status-line:has(#status[data-type="error"]) .status-dot {
  background: #e28383;
}

#status {
  color: #a9b9be;
  font-size: 11px;
  min-width: 0;
}

.warning {
  background: rgba(214, 178, 103, 0.08);
  border-left: 2px solid #cfa95d;
  color: #d8c18d;
  font-size: 11px;
  line-height: 1.5;
  margin-top: 10px;
  padding: 7px 9px;
  overflow-wrap: anywhere;
  grid-column: 1 / -1;
}

.preview-workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 650px;
}

.preview-header {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  /* The title owns the free space on its line; anything that has to wrap
     (the zoom slider on a narrow window) lands flush right underneath. */
  justify-content: flex-end;
  margin-bottom: 18px;
}

.preview-heading {
  flex: 0 0 auto;
  margin-bottom: 0;
  margin-right: auto;
}

.preview-heading h2 {
  font-size: 17px;
}

.preview-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 13px 18px;
  padding-top: 1px;
}

.preview-controls .background-tool {
  min-height: 32px;
}

.toggle-control,
.zoom-control {
  align-items: center;
  color: #9eafb4;
  display: inline-flex;
  font-size: 11px;
  gap: 7px;
  white-space: nowrap;
}

.toggle-control input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.toggle-track {
  background: #28353c;
  border: 1px solid #56676e;
  border-radius: 8px;
  display: inline-block;
  height: 16px;
  position: relative;
  transition: background 140ms ease, border-color 140ms ease;
  width: 28px;
}

.toggle-track::after {
  background: #a4b1b4;
  border-radius: 50%;
  content: "";
  height: 10px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition: transform 140ms ease, background 140ms ease;
  width: 10px;
}

.toggle-control input:checked + .toggle-track {
  background: #356150;
  border-color: #79d2aa;
}

.toggle-control input:checked + .toggle-track::after {
  background: #9ae0bd;
  transform: translateX(12px);
}

.toggle-control input:focus-visible + .toggle-track {
  outline: 2px solid #7fd3b1;
  outline-offset: 2px;
}

.zoom-control {
  border-left: 1px solid #334149;
  padding-left: 15px;
}

.zoom-control input[type="range"] {
  accent-color: #79d2aa;
  cursor: pointer;
  height: 16px;
  margin: 0;
  width: 106px;
}

.zoom-control output {
  color: #d3e2dc;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  min-width: 32px;
  text-align: right;
}

.preview-stage {
  align-items: center;
  background: #0a0e13;
  border: 1px solid #77848a;
  border-radius: 7px;
  box-shadow: 0 12px 24px rgba(5, 10, 13, 0.2);
  display: flex;
  flex: 1 1 auto;
  /* Horizontal positioning is driven by the pan transform in main.js, so the
     baseline must be "canvas left edge == stage content left edge"; auto
     margins still centre a canvas that is narrower than the stage. */
  justify-content: flex-start;
  min-height: 470px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px;
  scrollbar-color: #7f8c91 #1c252b;
  touch-action: pan-y;
}

.preview-stage.is-pannable {
  cursor: grab;
}

.preview-stage.is-panning {
  cursor: grabbing;
}

#preview-canvas {
  display: block;
  flex: 0 0 auto;
  image-rendering: pixelated;
  margin: auto;
  will-change: transform;
}

.metrics {
  border-top: 1px solid #2a3840;
  display: grid;
  gap: 0 20px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 19px;
  padding-top: 14px;
}

.site-render-count {
  color: #69777e;
  font-size: 10px;
  line-height: 1.4;
  margin: 0 auto;
  max-width: 1500px;
  padding: 0 30px 18px;
  text-align: center;
}

.metric {
  min-width: 0;
}

.metric-label {
  color: #809097;
  display: block;
  font-size: 10px;
}

.metric-value {
  color: #eef4f2;
  display: block;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  margin-top: 5px;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

@media (max-width: 1050px) {
  .app-shell {
    gap: 22px;
    grid-template-columns: minmax(290px, 350px) minmax(0, 1fr);
    padding-left: 22px;
    padding-right: 22px;
  }

  .preview-workspace {
    min-height: 650px;
  }

}

@media (max-width: 820px) {
  .app-header {
    background: #0e161b;
    margin-left: 0;
    min-height: 62px;
    padding: 0 18px;
  }

  .app-header:has(~ .app-layout.sidebar-collapsed) {
    margin-left: 0;
  }

  .app-shell {
    display: block;
    min-height: 0;
    padding: 22px 18px 30px;
  }

  .control-rail {
    margin-bottom: 22px;
  }

  .preview-workspace {
    min-height: 520px;
  }

  .preview-stage {
    min-height: 350px;
  }
}

/* Below roughly 600px all three controls no longer fit on the title row, but
   背景色 + 显示灰框 do once 背景色 is reduced to its colour swatch. Keep those
   two beside the title and push 缩放 onto a full-width row underneath. */
@media (max-width: 600px) {
  .preview-header {
    align-items: center;
  }

  .preview-controls {
    gap: 10px 12px;
  }

  /* 色块本身就是「当前背景色」的说明，窄屏只留色块换宽度 */
  .preview-controls > .background-tool {
    justify-content: center;
    min-height: 32px;
    padding: 0 5px;
  }

  .preview-controls > .background-tool .helper-summary-title {
    gap: 0;
  }

  .preview-controls > .background-tool .background-tool-label,
  .preview-controls > .background-tool .summary-arrow {
    display: none;
  }

  .zoom-control {
    border-left: 0;
    flex: 1 1 100%;
    padding-left: 0;
  }

  .zoom-control input[type="range"] {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }
}

@media (max-width: 500px) {
  .brand-kicker {
    display: none;
  }

  .header-status > span:nth-of-type(2) {
    display: none;
  }

  .app-shell {
    padding-left: 13px;
    padding-right: 13px;
  }

  .simulator-fields {
    grid-template-columns: 1fr;
  }

  .helper-tools {
    grid-template-columns: 1fr;
  }

  .simulator-fields .field:first-child,
  .simulator-fields .field-wide,
  .helper-tools {
    grid-column: auto;
  }

  .preview-actions {
    gap: 7px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-workspace {
    min-height: 520px;
  }

  .preview-stage {
    min-height: 280px;
    padding: 14px;
  }

  .metrics {
    gap: 14px 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* 手机上加粗行高、放宽箭头，否则上下箭头只有 18x13 根本按不中 */
  #score-table input {
    height: 32px;
  }

  .score-stepper {
    width: 26px;
  }
}

/* Workspace navigation */
.app-header {
  margin-left: 226px;
  position: relative;
  z-index: 30;
}

.app-header:has(~ .app-layout.sidebar-collapsed) {
  margin-left: 68px;
}

.header-leading {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.sidebar-toggle {
  align-items: center;
  background: #111b20;
  border-color: #344b4a;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 7px;
  height: 34px;
  justify-content: center;
  padding: 0 10px;
}

.sidebar-toggle:hover:not(:disabled) {
  background: #1c302e;
  border-color: #79d2aa;
}

.sidebar-toggle-icon {
  color: #9bdcc0;
  font-size: 17px;
  line-height: 1;
}

.sidebar-toggle-label {
  color: #bdd5cc;
  font-size: 11px;
  font-weight: 650;
}

.app-layout {
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
  min-height: calc(100vh - 66px);
  transition: grid-template-columns 180ms ease;
}

.app-layout.sidebar-collapsed {
  grid-template-columns: 68px minmax(0, 1fr);
}

.app-sidebar {
  background: #0e161b;
  border-right: 1px solid #25343a;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 25px;
  left: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px 14px 20px;
  position: fixed;
  top: 0;
  transition: padding 180ms ease, transform 180ms ease, width 180ms ease;
  width: 226px;
  z-index: 20;
}

.sidebar-heading {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 0 10px;
  transition: opacity 120ms ease;
}

.sidebar-heading strong {
  color: #edf5f1;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
}

.sidebar-eyebrow {
  color: #729082;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.sidebar-link {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #bdcbc9;
  display: flex;
  gap: 10px;
  min-height: 48px;
  min-width: 0;
  padding: 7px 10px;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.sidebar-link:hover {
  background: #162622;
  border-color: #38564c;
  color: #e5f2ec;
}

.sidebar-link[aria-current="page"] {
  background: #1b322b;
  border-color: #426b5a;
  color: #effff6;
}

.sidebar-link-icon {
  align-items: center;
  background: transparent;
  border: 0;
  color: #a1e3be;
  display: inline-flex;
  flex: 0 0 28px;
  font-size: 14px;
  height: 28px;
  justify-content: center;
  line-height: 1;
  width: 28px;
}

.sidebar-link-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
  transition: opacity 120ms ease, width 180ms ease;
}

.sidebar-link-copy strong {
  color: inherit;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.sidebar-link-copy small {
  color: #849893;
  font-size: 10px;
  white-space: nowrap;
}

.app-layout.sidebar-collapsed .app-sidebar {
  padding-left: 10px;
  padding-right: 10px;
  width: 68px;
}

.app-layout.sidebar-collapsed .sidebar-heading {
  height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0;
}

.app-layout.sidebar-collapsed .sidebar-link {
  gap: 0;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-layout.sidebar-collapsed .sidebar-link-copy {
  opacity: 0;
  width: 0;
}

.app-layout.sidebar-collapsed .sidebar-link-icon {
  margin-left: auto;
  margin-right: auto;
}

.page-content {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: calc(100vh - 66px);
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 820px) {
  .app-layout {
    display: block;
    min-height: 0;
  }

  .app-header,
  .app-header:has(~ .app-layout.sidebar-collapsed) {
    margin-left: 0;
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .app-sidebar {
    bottom: 0;
    box-shadow: 18px 0 42px rgba(0, 0, 0, 0.42);
    left: 0;
    position: fixed;
    top: 62px;
    transform: translateX(0);
    width: min(280px, calc(100vw - 42px));
    z-index: 25;
  }

  .app-layout.sidebar-collapsed .app-sidebar {
    padding-left: 14px;
    padding-right: 14px;
    transform: translateX(-110%);
    visibility: hidden;
  }

  .app-layout:not(.sidebar-collapsed) .app-sidebar {
    visibility: visible;
  }

  .app-layout.sidebar-collapsed .sidebar-heading {
    height: auto;
    opacity: 1;
    overflow: visible;
    padding: 0 10px;
  }

  .app-layout.sidebar-collapsed .sidebar-link {
    justify-content: flex-start;
    padding-left: 10px;
    padding-right: 10px;
  }

  .app-layout.sidebar-collapsed .sidebar-link-copy {
    opacity: 1;
    width: auto;
  }

  .sidebar-backdrop:not([hidden]) {
    background: rgba(4, 8, 10, 0.58);
    border: 0;
    bottom: 0;
    display: block;
    height: 100%;
    left: 0;
    padding: 0;
    position: fixed;
    right: 0;
    top: 0;
    width: 100%;
    z-index: 20;
  }

  .sidebar-toggle-label {
    display: none;
  }

  .page-content {
    min-height: 0;
  }
}

/* ===== T显展览 / 审核后台 ===== */
[hidden] {
  display: none !important;
}

.sidebar-link-icon svg {
  display: block;
  height: 18px;
  width: 18px;
}

.segmented {
  background: #0c1116;
  border: 1px solid #34414c;
  border-radius: 7px;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
}

.segmented-button {
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: #9eacb8;
  cursor: pointer;
  font-size: 12px;
  padding: 7px 14px;
  transition: background 120ms ease, color 120ms ease;
}

.segmented-button:hover {
  color: #e8edf2;
}

.segmented-button.is-active {
  background: #1f332b;
  color: #8fe0b0;
}

.tab-count {
  margin-left: 4px;
  opacity: 0.85;
}

.gallery-shell,
.admin-shell {
  margin: 0 auto;
  max-width: 1280px;
  padding: 26px 32px 48px;
}

.gallery-toolbar,
.admin-toolbar {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.gallery-toolbar-copy h1,
.admin-toolbar h1 {
  font-size: 22px;
  font-weight: 650;
  margin: 0 0 6px;
}

.gallery-toolbar-copy p,
.admin-toolbar p {
  color: #8c9aa6;
  font-size: 13px;
  margin: 0;
}

.gallery-toolbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.gallery-date-filter {
  align-items: center;
  display: flex;
  gap: 8px;
}

.gallery-date-filter input[type="date"],
.gallery-date-filter input[type="month"] {
  background: #0e161b;
  border: 1px solid #2c3e4a;
  border-radius: 8px;
  box-sizing: border-box;
  color: #e8eef2;
  color-scheme: dark;
  font-size: 13px;
  height: 34px;
  padding: 0 10px;
}

.gallery-date-filter input[type="date"]:focus,
.gallery-date-filter input[type="month"]:focus {
  border-color: #4a9fd8;
  outline: none;
}

.gallery-date-filter button {
  background: transparent;
  border: 1px solid #2c3e4a;
  border-radius: 8px;
  color: #8c9aa6;
  cursor: pointer;
  font-size: 13px;
  height: 34px;
  padding: 0 12px;
}

.gallery-date-filter button:hover {
  border-color: #e27575;
  color: #e27575;
}

.gallery-date-filter .month-menu-wrap {
  position: relative;
}

.gallery-date-filter .month-menu-toggle {
  white-space: nowrap;
}

.gallery-date-filter .month-menu-toggle.is-open {
  border-color: #4a9fd8;
  color: #e8eef2;
}

.month-menu {
  background: #0e161b;
  border: 1px solid #2c3e4a;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  left: 0;
  max-height: 320px;
  min-width: 148px;
  overflow-y: auto;
  position: absolute;
  top: calc(100% + 6px);
  z-index: 40;
}

.month-menu[hidden] {
  display: none;
}

.month-menu::-webkit-scrollbar {
  width: 6px;
}

.month-menu::-webkit-scrollbar-thumb {
  background: #2f6f9f;
  border-radius: 3px;
}

.month-menu::-webkit-scrollbar-track {
  background: transparent;
}

.month-menu-item {
  background: transparent;
  border: 0;
  color: #b9c6d2;
  cursor: pointer;
  display: block;
  font-size: 13px;
  padding: 9px 14px;
  text-align: left;
  width: 100%;
}

.month-menu-item:hover {
  background: rgba(74, 159, 216, 0.12);
  color: #e8eef2;
}

.month-menu-item.is-selected {
  background: rgba(74, 159, 216, 0.15);
  color: #7cc0f0;
  font-weight: 600;
}

.gallery-date-filter[hidden],
.gallery-date-filter input[hidden],
.gallery-date-filter button[hidden] {
  display: none;
}

.gallery-pagination {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.gallery-pagination[hidden] {
  display: none;
}

.gallery-pagination .page-jump,
.gallery-pagination .page-number {
  background: transparent;
  border: 1px solid #2c3e4a;
  border-radius: 8px;
  color: #b9c6d2;
  cursor: pointer;
  font-size: 13px;
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.gallery-pagination .page-jump:hover:not(:disabled),
.gallery-pagination .page-number:hover:not(:disabled) {
  border-color: #4a9fd8;
  color: #e8eef2;
}

.gallery-pagination .page-number.is-active {
  background: #2f6f9f;
  border-color: #2f6f9f;
  color: #fff;
  cursor: default;
  font-weight: 600;
}

.gallery-pagination .page-jump:disabled {
  cursor: default;
  opacity: 0.35;
}

.gallery-pagination .page-ellipsis {
  color: #8c9aa6;
  font-size: 13px;
  padding: 0 2px;
}

.gallery-pagination .page-numbers {
  align-items: center;
  display: flex;
  gap: 6px;
}

.gallery-feedback {
  border-left: 2px solid #65c18c;
  background: rgba(101, 193, 140, 0.1);
  border-radius: 4px;
  color: #bfe6cd;
  font-size: 13px;
  margin: 0 0 16px;
  padding: 9px 12px;
  /* 转换失败时会显示引擎的原始输出，可能很长：
     保证长串能换行，并限制高度、超出可滚动，避免撑破版面 */
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
}

.gallery-feedback[data-type="error"] {
  border-left-color: #e27575;
  background: rgba(226, 117, 117, 0.1);
  color: #efb4b4;
}

.gallery-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.gallery-card {
  background: #11171d;
  border: 1px solid #26313a;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 140ms ease, transform 140ms ease;
}

.gallery-card:hover {
  border-color: #3c5048;
}

.gallery-card-image {
  align-items: center;
  background: #0a0e13;
  display: flex;
  justify-content: center;
  min-height: 96px;
  overflow: hidden;
  padding: 16px;
}

.gallery-card-img {
  display: block;
  height: auto;
  image-rendering: pixelated;
  max-width: 100%;
}

.gallery-card-body {
  border-top: 1px solid #202a32;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 15px 15px;
}

.gallery-card-title {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-title-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.gallery-card-title-row .gallery-card-title {
  flex: 1 1 auto;
}

.gallery-card-author {
  color: #849893;
  font-size: 12px;
  line-height: 1.4;
}

.gallery-card-reject {
  color: #f08484;
  font-size: 12px;
  line-height: 1.4;
}

.status-badge {
  border-radius: 999px;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
}

.status-pending {
  background: rgba(240, 176, 106, 0.12);
  border: 1px solid rgba(240, 176, 106, 0.45);
  color: #f0b06a;
}

.status-approved {
  background: rgba(161, 227, 190, 0.12);
  border: 1px solid rgba(161, 227, 190, 0.45);
  color: #a1e3be;
}

.status-rejected {
  background: rgba(240, 132, 132, 0.12);
  border: 1px solid rgba(240, 132, 132, 0.45);
  color: #f08484;
}

.gallery-card-meta {
  display: grid;
  gap: 6px;
}

.meta-summary {
  color: #8c9aa6;
  font-size: 12px;
  margin: 0;
}

.meta-toggle {
  background: none;
  border: 0;
  color: #7fb897;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-align: left;
  width: fit-content;
}

.meta-toggle.is-open {
  color: #a1e3be;
}

.meta-panel {
  background: #0c1116;
  border: 1px solid #232f38;
  border-radius: 6px;
  display: grid;
  gap: 5px;
  padding: 9px 10px;
}

.meta-row {
  display: flex;
  font-size: 12px;
  gap: 10px;
  justify-content: space-between;
}

.meta-label {
  color: #8c9aa6;
  flex: 0 0 auto;
}

.meta-value {
  color: #cfd9e0;
  text-align: right;
  word-break: break-all;
}

.gallery-card-row {
  align-items: center;
  border-top: 1px solid #1d272f;
  display: flex;
  font-size: 12px;
  gap: 10px;
  justify-content: space-between;
  padding-top: 9px;
}

.row-label {
  color: #8c9aa6;
}

.row-value {
  color: #cfd9e0;
}

.gallery-card-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.card-action {
  align-items: center;
  background: #16202a;
  border: 1px solid #31414d;
  border-radius: 6px;
  color: #cfd9e0;
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 12px;
  justify-content: center;
  line-height: 1;
  padding: 8px 9px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.card-action svg {
  display: block;
}

/* 复制成功：按钮变蓝并显示「已复制」文字（持续 1.4 秒，由 gallery.js 控制） */
.card-action.is-copied,
.card-action.is-copied:hover {
  background: #16324d;
  border-color: #4c8fd6;
  color: #a9cdf2;
}

.card-action:hover {
  border-color: #718394;
  color: #eef3f7;
}

.vote-group {
  display: inline-flex;
  flex-shrink: 0;
  gap: 6px;
  margin-left: auto;
}

.vote-button {
  background: #16202a;
  border: 1px solid #31414d;
  border-radius: 6px;
  color: #9eacb8;
  cursor: pointer;
  font-size: 12px;
  padding: 7px 10px;
  white-space: nowrap;
}

.vote-button:hover {
  border-color: #718394;
  color: #eef3f7;
}

.vote-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.vote-up.is-active {
  background: rgba(101, 193, 140, 0.16);
  border-color: #65c18c;
  color: #8fe0b0;
}

.vote-down.is-active {
  background: rgba(226, 117, 117, 0.16);
  border-color: #e27575;
  color: #efb4b4;
}

.gallery-empty,
.gallery-loading {
  color: #8c9aa6;
  font-size: 14px;
  padding: 60px 0;
  text-align: center;
}

.gallery-empty p {
  font-size: 15px;
  margin: 0 0 6px;
  color: #bdc8d0;
}

/* 上传对话框 */
.upload-dialog {
  background: #11171d;
  border: 1px solid #34414c;
  border-radius: 12px;
  color: #e8edf2;
  max-height: 90vh;
  overflow-x: hidden;
  padding: 0;
  width: min(720px, 94vw);
}

.upload-dialog::backdrop {
  background: rgba(4, 8, 10, 0.66);
}

.upload-form {
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-height: 90vh;
  min-width: 0;
}

.upload-header {
  align-items: flex-start;
  border-bottom: 1px solid #26313a;
  display: flex;
  justify-content: space-between;
  padding: 18px 20px;
}

.upload-header h2 {
  font-size: 16px;
  font-weight: 650;
  margin: 0 0 4px;
}

.upload-header p {
  color: #8c9aa6;
  font-size: 12px;
  margin: 0;
}

.upload-notice {
  background: rgba(180, 130, 40, 0.12);
  border: 1px solid rgba(200, 150, 50, 0.35);
  border-radius: 5px;
  color: #e0b870 !important;
  font-size: 11.5px !important;
  line-height: 1.5;
  margin-top: 8px !important;
  padding: 7px 10px;
}

.icon-close {
  background: none;
  border: 0;
  color: #9eacb8;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.icon-close:hover {
  color: #eef3f7;
}

.upload-body {
  display: grid;
  gap: 15px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 20px;
}

.upload-body .field {
  display: grid;
  gap: 7px;
}

.upload-body label {
  color: #bdc8d0;
  font-size: 12px;
}

.upload-input {
  background: #0c1116;
  border: 1px solid #34414c;
  border-radius: 5px;
  color: #eef3f7;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  min-height: 110px;
  padding: 10px 11px;
  resize: vertical;
  width: 100%;
}

.upload-simulator summary {
  color: #bdc8d0;
  cursor: pointer;
  font-size: 12px;
}

.upload-simulator-body {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.upload-simulator-grid {
  display: grid;
  gap: 12px;
  /* 与模拟玩家区一致：名称窄、tag 占满剩余宽度 */
  grid-template-columns: 180px minmax(0, 1fr);
}

.upload-simulator-grid .field-wide {
  grid-column: 2;
}

.upload-preview-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.upload-preview-head span {
  color: #bdc8d0;
  font-size: 12px;
}

.upload-preview-stage {
  align-items: center;
  background: #0a0e13;
  border: 1px solid #33404b;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  min-height: 120px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px;
  position: relative;
}

.upload-preview-stage canvas {
  height: auto;
  image-rendering: pixelated;
  max-width: 100%;
}

.upload-preview-stage span {
  color: #697887;
  font-size: 12px;
  text-align: center;
  width: 100%;
}

.upload-footer {
  border-top: 1px solid #26313a;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
}

/* 审核后台 */
.admin-login {
  display: flex;
  justify-content: center;
  padding: 8vh 0;
}

.admin-login-card {
  background: #11171d;
  border: 1px solid #26313a;
  border-radius: 12px;
  max-width: 400px;
  padding: 28px;
  width: 100%;
}

.admin-login-card h1 {
  font-size: 18px;
  margin: 0 0 8px;
}

.admin-login-card p {
  color: #8c9aa6;
  font-size: 13px;
  margin: 0 0 18px;
}

.admin-login-card form {
  display: grid;
  gap: 12px;
}

.admin-login-card label {
  color: #bdc8d0;
  font-size: 12px;
}

.admin-summary {
  color: #8c9aa6;
  font-size: 13px;
  margin: 6px 0 0;
}

.admin-tabs {
  margin-bottom: 18px;
}

.admin-bulk-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.admin-bulk-actions .danger-button {
  font-size: 13px;
}

.admin-list {
  display: grid;
  gap: 16px;
}

.admin-card {
  background: #11171d;
  border: 1px solid #26313a;
  border-radius: 10px;
  display: grid;
  gap: 0;
  grid-template-columns: minmax(240px, 360px) 1fr;
  overflow: hidden;
}

.admin-card-rejected {
  border-color: #4a3030;
}

.admin-card-approved {
  border-color: #2c4638;
}

.admin-card-image {
  align-items: center;
  background: #0a0e13;
  display: flex;
  justify-content: center;
  min-height: 140px;
  overflow: auto;
  padding: 16px;
}

.admin-card-image img {
  image-rendering: pixelated;
  max-width: 100%;
}

.admin-card-body {
  border-left: 1px solid #202a32;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px 18px;
}

.admin-card-title {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
}

.admin-card-row {
  color: #9eacb8;
  font-size: 12px;
}

.admin-section-label {
  color: #8c9aa6;
  font-size: 12px;
}

.admin-pre {
  background: #0c1116;
  border: 1px solid #232f38;
  border-radius: 6px;
  color: #cfd9e0;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

.admin-input-pre {
  max-height: 150px;
}

.admin-simulator summary {
  color: #7fb897;
  cursor: pointer;
  font-size: 12px;
}

.admin-reason {
  display: grid;
  gap: 6px;
}

.admin-reason label {
  color: #bdc8d0;
  font-size: 12px;
}


.admin-card-detail {
  border-top: 1px dashed #2c4554;
  margin-top: 10px;
  padding-top: 10px;
}

.admin-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 4px;
}

.danger-button {
  border-color: #5a3a3a;
  color: #efb4b4;
}

.danger-button:hover:not(:disabled) {
  background: #2e2020;
  border-color: #e27575;
}

@media (max-width: 820px) {
  .gallery-shell,
  .admin-shell {
    padding: 20px 16px 36px;
  }

  .admin-card {
    grid-template-columns: 1fr;
  }

  .admin-card-body {
    border-left: 0;
    border-top: 1px solid #202a32;
  }

  .upload-simulator-grid {
    grid-template-columns: 1fr;
  }

  /* 单列时不能再用 grid-column: 2 —— 那会凭空多出一个隐式列把 tag 挤出去 */
  .upload-simulator-grid .field-wide {
    grid-column: auto;
  }
}

/* ===== 账号系统 / 收藏 ===== */
.sidebar-auth {
  border-top: 1px solid #25343a;
  margin-top: auto;
  padding-top: 14px;
}

.sidebar-auth-button {
  align-items: center;
  background: #14241f;
  border: 1px solid #2f4a40;
  border-radius: 6px;
  color: #b9e6cd;
  cursor: pointer;
  display: flex;
  font-size: 12px;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  transition: background 140ms ease, border-color 140ms ease;
  width: 100%;
}

.sidebar-auth-button:hover {
  background: #1b322b;
  border-color: #426b5a;
}

.sidebar-auth-icon,
.sidebar-user-icon {
  align-items: center;
  color: #a1e3be;
  display: flex;
  flex: 0 0 auto;
  font-size: 14px;
  height: 22px;
  justify-content: center;
  line-height: 1;
  position: relative;
  width: 22px;
}

.sidebar-user-avatar {
  border-radius: 50%;
  display: block;
  height: 100%;
  left: 0;
  object-fit: cover;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 1;
}

.sidebar-auth-text,
.sidebar-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 36px;
}

.sidebar-user-name {
  color: #e5f2ec;
  flex: 1 1 auto;
  font-size: 12px;
  font-weight: 600;
}

.sidebar-logout {
  background: transparent;
  border: 1px solid #33414c;
  border-radius: 5px;
  color: #9eacb8;
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 11px;
  padding: 4px 8px;
}

.sidebar-logout:hover {
  background: #2a1d1d;
  border-color: #5c3a3a;
  color: #f0b4b4;
}

.app-layout.sidebar-collapsed .sidebar-auth-button {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-layout.sidebar-collapsed .sidebar-auth-text,
.app-layout.sidebar-collapsed .sidebar-user-name,
.app-layout.sidebar-collapsed .sidebar-logout {
  display: none;
}

.app-layout.sidebar-collapsed .sidebar-user {
  justify-content: center;
}

/* 登录 / 注册对话框 */
.auth-dialog {
  background: #11171d;
  border: 1px solid #34414c;
  border-radius: 12px;
  color: #e8edf2;
  max-height: 90vh;
  overflow-x: hidden;
  padding: 0;
  width: min(420px, 94vw);
}

.auth-dialog::backdrop {
  background: rgba(4, 8, 10, 0.66);
}

.auth-form {
  display: grid;
  grid-template-rows: auto 1fr;
  max-height: 90vh;
  min-width: 0;
}

.auth-tabs {
  margin-bottom: 2px;
}

.auth-dialog-hint {
  color: #e0b870;
  font-size: 12px;
  margin-top: 6px;
}

/* 通用确认弹窗（confirmDialog）：花积分这类不能点错的操作先弹它 */
.confirm-dialog {
  background: #11171d;
  border: 1px solid #34414c;
  border-radius: 12px;
  color: #e8edf2;
  padding: 18px 20px 16px;
  width: min(400px, 92vw);
}

.confirm-dialog::backdrop {
  background: rgba(4, 8, 10, 0.66);
}

.confirm-dialog h2 {
  font-size: 15px;
  margin: 0 0 10px;
}

.confirm-dialog-message {
  color: #b7c5cc;
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 16px;
  white-space: pre-line;
}

.confirm-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-dialog-actions .action-button {
  min-width: 92px;
  text-align: center;
}

.auth-panel {
  display: grid;
  gap: 14px;
}

.auth-panel .field input {
  box-sizing: border-box;
  width: 100%;
}

.auth-warning {
  background: rgba(224, 184, 112, 0.08);
  border: 1px solid rgba(224, 184, 112, 0.35);
  border-radius: 6px;
  color: #e0b870;
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  padding: 8px 10px;
}

.auth-submit {
  margin-top: 2px;
  width: 100%;
}

/* 密码显示/隐藏 */
.password-field-wrap {
  position: relative;
}

.password-field-wrap input {
  padding-right: 38px;
}

.password-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #6d8188;
  cursor: pointer;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  padding: 0;
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
}

.password-toggle:hover {
  color: #9bdcc0;
}

.password-toggle svg {
  display: block;
}

/* 登录弹窗：忘记密码 / 密保找回 */
.auth-forgot-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -6px;
}

.auth-forgot-link {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #8fb6c8;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

.auth-forgot-link:hover {
  background: transparent;
  border: 0;
  color: #9bdcc0;
  text-decoration: underline;
}

.auth-forgot-desc {
  color: #aebfca;
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0;
}

.auth-forgot-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.auth-forgot-actions .action-button {
  min-width: 96px;
}

/* 收藏按钮 */
.favorite-button {
  color: #b9c4cd;
}

.favorite-button.is-active {
  color: #f0b06a;
}

.favorite-button:hover {
  color: #f5c98c;
}

/* ===== 用户中心 ===== */
.user-shell {
  margin: 0 auto;
  max-width: 860px;
  padding: 28px 20px 48px;
}

.user-unauth {
  background: #10161b;
  border: 1px solid #1d2830;
  border-radius: 14px;
  padding: 44px 24px;
  text-align: center;
}

.user-unauth h1 {
  font-size: 22px;
  margin: 0 0 10px;
}

.user-unauth p {
  color: #8ea2ad;
  margin: 0 0 20px;
}

.user-panel {
  display: grid;
  gap: 18px;
}

.user-profile {
  align-items: flex-start;
  background: #10161b;
  border: 1px solid #1d2830;
  border-radius: 14px;
  display: flex;
  gap: 18px;
  padding: 20px;
}

.user-avatar-wrap {
  align-items: center;
  background: #172029;
  border-radius: 14px;
  display: flex;
  flex: 0 0 auto;
  height: 96px;
  justify-content: center;
  overflow: hidden;
  position: relative;
  width: 96px;
}

.user-avatar-wrap::before {
  align-items: center;
  color: #5f7480;
  content: "👤";
  display: flex;
  font-size: 44px;
  inset: 0;
  justify-content: center;
  line-height: 1;
  position: absolute;
}

.user-avatar {
  display: block;
  height: 100%;
  object-fit: cover;
  position: absolute;
  width: 100%;
  z-index: 1;
}

.user-avatar-status {
  background: rgba(11, 16, 20, 0.82);
  border-radius: 999px;
  bottom: 6px;
  color: #cdd9de;
  font-size: 11px;
  left: 50%;
  line-height: 1;
  padding: 4px 8px;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 2;
}

.user-info {
  flex: 1 1 auto;
  min-width: 0;
}

.user-info h1 {
  font-size: 24px;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.user-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.user-role-badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 10px;
}

.user-role-badge[data-role="admin"] {
  background: rgba(240, 176, 106, 0.14);
  border: 1px solid rgba(240, 176, 106, 0.5);
  color: #f0b06a;
}

/* 超级管理员（等同后台密码那档权限，只能手工写进数据文件）：用更醒目的红金区分 */
.user-role-badge[data-role="super"] {
  background: rgba(232, 108, 108, 0.16);
  border: 1px solid rgba(232, 108, 108, 0.55);
  color: #f08a8a;
}

.user-role-badge[data-role="user"] {
  background: rgba(106, 168, 220, 0.14);
  border: 1px solid rgba(106, 168, 220, 0.45);
  color: #7db8e8;
}

.user-created {
  color: #8ea2ad;
  font-size: 13px;
}

.user-points-box {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.user-points-label {
  color: #8ea2ad;
  font-size: 13px;
}

.user-points-value {
  color: #f0b06a;
  font-size: 22px;
}

.user-section {
  background: #10161b;
  border: 1px solid #1d2830;
  border-radius: 14px;
  padding: 18px 20px;
}

.user-section h2 {
  font-size: 16px;
  margin: 0 0 6px;
}

.user-section-hint {
  color: #8ea2ad;
  font-size: 13px;
  margin: 0 0 14px;
}

.avatar-upload-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* 原生 file 控件右侧会固定带一段“未选择文件”文字，无法单独隐藏，
   因此把它视觉隐藏，只保留自定义的“选择文件”按钮触发它。 */
.avatar-file-input {
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* .gallery-feedback 默认只有下外边距(margin: 0 0 16px)，
   放在这里会紧贴上面的「选择文件」按钮，看起来像重叠，所以单独补上间距 */
.avatar-feedback {
  margin: 12px 0 0;
}

.user-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* 修改密码 / 密保问题 */
.security-form {
  display: grid;
  gap: 14px;
  max-width: 420px;
}

.security-editor {
  display: grid;
  gap: 14px;
}

.security-form .field,
.security-editor .field {
  margin: 0;
}

.security-form .field input,
.security-editor .field input,
.security-form .password-field-wrap,
.security-editor .password-field-wrap {
  box-sizing: border-box;
  display: block;
  width: 100%;
}

.security-form .password-field-wrap input,
.security-editor .password-field-wrap input {
  width: 100%;
}

.security-fold-summary {
  align-items: flex-start;
  cursor: default;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  user-select: none;
}

.security-fold-summary::-webkit-details-marker {
  display: none;
}

.security-fold-copy {
  min-width: 0;
}

.security-fold-copy .user-section-hint {
  margin-bottom: 0;
}

.security-fold-meta {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
  margin-top: 2px;
}

.security-fold-status {
  background: rgba(123, 210, 170, 0.12);
  border: 1px solid rgba(123, 210, 170, 0.35);
  border-radius: 999px;
  color: #9bdcc0;
  font-size: 12px;
  padding: 3px 8px;
  white-space: nowrap;
}

.security-fold .summary-arrow {
  color: #7e9098;
  display: none;
  font-size: 18px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 140ms ease;
}

.security-fold.is-collapsible .security-fold-summary {
  cursor: pointer;
}

.security-fold.is-collapsible .summary-arrow {
  display: inline-block;
}

.security-fold.is-collapsible:not([open]) .summary-arrow {
  transform: rotate(-90deg);
}

.security-fold.is-collapsible[open] .security-fold-summary {
  margin-bottom: 14px;
}

.security-fold.is-collapsible:not([open]) #security-root,
.security-fold.is-collapsible:not([open]) #security-feedback {
  display: none;
}

.security-fold #security-edit {
  font-size: 12px;
  padding: 5px 10px;
}

.security-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.security-feedback {
  margin: 0;
}

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

.security-view {
  max-width: 560px;
}

.security-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}

.security-list li {
  align-items: baseline;
  background: #0d1318;
  border: 1px solid #1d2830;
  border-radius: 9px;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
}

.sq-index {
  align-items: center;
  background: #1d2c34;
  border-radius: 50%;
  color: #9bdcc0;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  height: 20px;
  justify-content: center;
  width: 20px;
}

.sq-text {
  color: #dfe8ec;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

@media (max-width: 560px) {
  .security-row {
    grid-template-columns: 1fr;
  }
}

.sidebar-user-links {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 0 8px;
}

.sidebar-user-action {
  background: #172029;
  border: 1px solid #2a3944;
  border-radius: 8px;
  color: #aebfca;
  flex: 1 1 auto;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  padding: 8px 6px;
  text-align: center;
  text-decoration: none;
}

.sidebar-user-action:hover {
  border-color: #55708a;
  color: #e7edf0;
}

.sidebar-user-action.is-admin {
  background: rgba(64, 128, 226, 0.16);
  border-color: rgba(86, 150, 244, 0.6);
  color: #5aa0f0;
  font-weight: 700;
  text-align: center;
}

.sidebar-user-action.is-admin:hover {
  border-color: #6fb0ff;
  color: #8cc2ff;
}

.app-layout.sidebar-collapsed .sidebar-user {
  gap: 0;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-layout.sidebar-collapsed .sidebar-user-icon {
  margin-left: auto;
  margin-right: auto;
}

.app-layout.sidebar-collapsed .sidebar-user-links {
  display: none;
}

/* ===== 后台：登录切换 / 身份徽章 / 新面板 ===== */
.admin-login-tabs {
  margin-bottom: 16px;
}

.admin-login-note {
  color: #8ea2ad;
  font-size: 12px;
  line-height: 1.8;
  margin: 14px 0 0;
  text-align: center;
}

.admin-level-badge {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
  padding: 4px 10px;
  vertical-align: middle;
}

.admin-level-badge[data-level="super"] {
  background: rgba(240, 176, 106, 0.14);
  border: 1px solid rgba(240, 176, 106, 0.5);
  color: #f0b06a;
}

.admin-level-badge[data-level="user"] {
  background: rgba(106, 168, 220, 0.14);
  border: 1px solid rgba(106, 168, 220, 0.45);
  color: #7db8e8;
}

.admin-view-pane {
  margin-top: 16px;
}

.admin-pane-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.admin-pane-head h2 {
  font-size: 16px;
  margin: 0;
}

.user-search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.user-search-row input {
  background: #10161b;
  border: 1px solid #24333c;
  border-radius: 8px;
  color: #e7edf0;
  flex: 1 1 auto;
  font-size: 14px;
  padding: 9px 12px;
}

.user-search-row input:focus {
  border-color: #9bdcc0;
  outline: none;
}

.admin-card-user .admin-card-body {
  display: grid;
  gap: 10px;
}

.admin-card-user .admin-card-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-card-user .admin-card-title {
  margin: 0;
}

.user-points-input {
  background: #10161b;
  border: 1px solid #24333c;
  border-radius: 8px;
  color: #e7edf0;
  font-size: 13px;
  padding: 7px 10px;
  width: 110px;
}

.user-points-input:focus {
  border-color: #9bdcc0;
  outline: none;
}

@media (max-width: 600px) {
  .user-profile {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .user-meta {
    justify-content: center;
  }
  .user-points-box {
    justify-content: center;
  }
  .user-actions {
    justify-content: stretch;
  }
  .user-actions .action-button {
    flex: 1 1 auto;
    text-align: center;
  }
  
.admin-card-detail {
  border-top: 1px dashed #2c4554;
  margin-top: 10px;
  padding-top: 10px;
}

.admin-card-actions {
    flex-wrap: wrap;
  }
}

/* ===== 画廊文字固定横排 ===== */
.gallery-card,
.gallery-card *,
.gallery-empty,
.gallery-loading {
  writing-mode: horizontal-tb;
}

.gallery-card-title,
.gallery-card-author,
.gallery-card-reject,
.gallery-card-row,
.meta-summary,
.meta-toggle {
  writing-mode: horizontal-tb;
}

.card-action,
.vote-button,
.meta-toggle {
  white-space: nowrap;
}

.gallery-card-title {
  overflow-wrap: anywhere;
}

/* ===== 头像裁剪弹窗 ===== */
.crop-dialog {
  background: #11171d;
  border: 1px solid #34414c;
  border-radius: 14px;
  color: #e7edf0;
  max-width: min(420px, calc(100vw - 32px));
  padding: 18px;
  width: 420px;
}

.crop-dialog::backdrop {
  background: rgba(5, 8, 10, 0.66);
}

.crop-dialog h2 {
  font-size: 17px;
  margin: 0 0 4px;
}

.crop-hint {
  color: #8ea2ad;
  font-size: 12px;
  margin: 0 0 14px;
}

.crop-stage {
  background: #080b0e;
  border: 1px solid #26313a;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.crop-canvas {
  display: block;
  height: auto;
  touch-action: none;
  user-select: none;
  width: 100%;
}

.crop-mask {
  border: 2px solid #9bdcc0;
  border-radius: 2px;
  box-shadow: 0 0 0 9999px rgba(5, 8, 10, 0.45);
  height: calc(100% - 12px);
  left: 6px;
  pointer-events: none;
  position: absolute;
  top: 6px;
  width: calc(100% - 12px);
}

.crop-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ===== convert page ===== */
.convert-shell {
  margin: 0 auto;
  max-width: 860px;
  padding: 26px 32px 48px;
}


.convert-limit-badge {
  align-self: center;
  background: #16232b;
  border: 1px solid #2c4554;
  border-radius: 999px;
  color: #8fd0b8;
  font-size: 12px;
  margin-left: auto;
  padding: 4px 10px;
  white-space: nowrap;
}

.convert-toolbar {
  margin-bottom: 18px;
}

.convert-toolbar-copy h1 {
  font-size: 22px;
  font-weight: 650;
  margin: 0 0 6px;
}

.convert-toolbar-copy p {
  color: #8c9aa6;
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}


.user-limit-badge {
  background: #16232b;
  border: 1px solid #2c4554;
  border-radius: 999px;
  color: #8fd0b8;
  font-size: 11px;
  margin-left: 8px;
  padding: 2px 8px;
}

/* 权限等级标签：折叠状态下也显示在账号名旁边 */
.user-role-badge {
  background: #16232b;
  border: 1px solid #2c4554;
  border-radius: 999px;
  color: #93a6b0;
  font-size: 11px;
  padding: 2px 8px;
}

.user-role-badge.is-admin {
  background: #2a2313;
  border-color: #6b5a2a;
  color: #e8c46a;
}

.user-role-badge.is-super {
  background: #2c1416;
  border-color: #74343a;
  color: #f08a8a;
}

.convert-gate {
  align-items: center;
  background: #1c2a26;
  border: 1px solid #2e5c4a;
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 16px 20px;
}

.convert-gate p {
  color: #d7e4de;
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.convert-card {
  background: #10161b;
  border: 1px solid #1d2830;
  border-radius: 14px;
  margin-bottom: 16px;
  padding: 20px;
}

.convert-card h2 {
  font-size: 16px;
  margin: 0;
}

.convert-drop {
  align-items: flex-start;
  background: #0b1115;
  border: 1px dashed #33444e;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  padding: 22px 18px;
}

.convert-drop:hover,
.convert-drop.is-hover {
  border-color: #72cda6;
  box-shadow: 0 0 0 2px rgba(114, 205, 166, 0.12);
}

.convert-drop.has-file {
  border-color: #3d6f5d;
  border-style: solid;
}

.convert-drop.is-busy {
  cursor: wait;
  opacity: 0.72;
  pointer-events: none;
}

.convert-drop strong {
  color: #edf4f4;
  font-size: 14px;
}

.convert-drop span {
  color: #8c9aa6;
  font-size: 12px;
  line-height: 1.55;
}

.convert-note {
  color: #8c9aa6;
  font-size: 12px;
  line-height: 1.55;
  margin: 12px 0 0;
}

/* 卡片内的状态/报错条：上方也要留出间距，否则会贴着进度条或拖放区 */
.convert-card > .gallery-feedback:not([hidden]) {
  margin: 14px 0 16px;
}
.convert-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
#convert-detect {
  color: #edf4f4;
  display: block;
  font-size: 13px;
  margin-top: 8px;
}

.convert-detect[hidden] {
  display: none;
}

/* 拖放区里的每个子项都必须能换行、不能撑出盒子。
   长文件名、英文长报错（没有空格）会把 flex 子项顶宽，视觉上就像和别的元素"重叠"了。 */
.convert-drop > * {
  max-width: 100%;
  min-width: 0;
}

.convert-drop,
.convert-drop-error {
  overflow-wrap: anywhere;
}

/* 选择存档阶段的报错（文件类型不对 / 过大 / 上传失败）。
   放在拖放区里，用户选完文件就能当场看到，不必等到点"开始转换"。
   ⚠️ 这里用**类**选择器而不是 #convert-drop-error：存档编辑页的 id 是
   world-drop-error，以前只写了 id，那一页的报错框等于完全没有样式。 */
.convert-drop-error {
  color: #f0a4a4;
  display: block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  margin: 10px 0 0;
  width: 100%;
}

/* 夹在拖放区与进度条之间时，上下都要留白，避免看成一坨 */
.convert-card > .convert-drop-error:not([hidden]) {
  margin: 10px 0 2px;
}

.convert-drop-error[hidden],
.convert-file-meta[hidden] {
  display: none;
}

.convert-file-meta {
  color: #edf4f4;
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* 存档编辑页：当前存档信息分两行（大字存档名 + 小字类型/版本/大小）。
   只限定 #world-file-meta，不影响存档转换页同 class 的单行文本。 */
#world-file-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* 上传完成后的当前存档：存档名绿色大字、一眼能看到；类型/版本/大小压一行小字。
   选择器带 .convert-drop 前缀以覆盖 .convert-drop strong/span 的通用字号字色。 */
.convert-drop .world-active-name {
  color: #72cda6;
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
}

.convert-drop .world-active-meta {
  color: #8c9aa6;
  display: block;
  font-size: 12px;
  line-height: 1.5;
}

.convert-history-list[hidden] {
  display: none;
}

.convert-history-item {
  align-items: center;
  background: #0b1115;
  border: 1px solid #26343c;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
}

.convert-history-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.convert-history-name {
  color: #e8eef2;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.convert-history-meta {
  color: #8c9aa6;
  font-size: 12px;
}

.convert-history-download {
  flex-shrink: 0;
  text-decoration: none;
}

/* 转换页「版本类型 / 目标版本」两个字段的容器。
   .field 自身没有垂直间距，连续放两个会紧贴在一起（看起来像叠在一起）。 */
.convert-fields {
  display: grid;
  gap: 14px;
}

.convert-card select {
  appearance: none;
  background: #0b1115;
  border: 1px solid #35454e;
  border-radius: 5px;
  color: #edf4f4;
  font-size: 13px;
  height: 38px;
  padding: 0 10px;
  width: 100%;
}

.convert-card select:focus {
  border-color: #72cda6;
  box-shadow: 0 0 0 2px rgba(114, 205, 166, 0.12);
  outline: none;
}

.convert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

/* 选择存档卡片里「删除并退出」与上传框拉开距离 */
.world-delete-actions {
  margin-top: 16px;
}

/* 「保存设置」按钮行下方的就地反馈，与按钮拉开距离 */
.world-settings-feedback {
  margin: 12px 0 0;
}

/* 导出下载链接：世界名可能很长且无空格，允许换行并独占一行，避免撑破卡片 */
#world-download:not([hidden]) {
  flex-basis: 100%;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
  width: 100%;
}

.convert-progress-wrap {
  margin-top: 16px;
}

.convert-progress-head {
  align-items: center;
  color: #9cabb0;
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.convert-progress {
  background: #0b1115;
  border: 1px solid #26313a;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.convert-progress span {
  background: linear-gradient(90deg, #4ea57f, #79d2aa);
  display: block;
  height: 100%;
  width: 0;
}

/* ---------------- 存档编辑（/world） ---------------- */

/* 预览页要同时放画框、控件和导出面板，比转换页更吃横向宽度，单独放宽 */
.world-shell {
  max-width: 1120px;
}

.world-preview {
  display: grid;
  gap: 18px;
  grid-template-columns: 240px minmax(0, 1fr);
}

@media (max-width: 960px) {
  .world-preview {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 宽屏世界设置两列排，世界重生点跨整行；窄屏自然回单列 */
@media (min-width: 961px) {
  .world-shell .convert-fields {
    grid-template-columns: 1fr 1fr;
  }
  .world-shell .convert-fields .field-wide {
    grid-column: 1 / -1;
  }
}

.world-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.world-controls .field label strong {
  color: #9ed9be;
  font-size: 12px;
}

.world-y-scale {
  color: #7d8b96;
  display: flex;
  font-size: 11px;
  justify-content: space-between;
  margin-top: 4px;
}

.world-hint {
  color: #6f7d88;
  font-size: 11px;
  line-height: 1.5;
  margin: 6px 0 0;
}

.world-controls input[type="range"] {
  appearance: none;
  background: #0b1115;
  border: 1px solid #26313a;
  border-radius: 999px;
  height: 10px;
  margin: 6px 0 0;
  width: 100%;
}

.world-controls input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  background: linear-gradient(180deg, #79d2aa, #4ea57f);
  border: 1px solid #2c5f4a;
  border-radius: 50%;
  cursor: grab;
  height: 18px;
  width: 18px;
}

.world-controls input[type="range"]::-moz-range-thumb {
  background: #79d2aa;
  border: 1px solid #2c5f4a;
  border-radius: 50%;
  height: 16px;
  width: 16px;
}

.world-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.world-toggle {
  align-items: center;
  color: #c4d0d6;
  cursor: pointer;
  display: flex;
  font-size: 12px;
  gap: 8px;
}

.world-toggle input {
  accent-color: #4ea57f;
  height: 14px;
  width: 14px;
}

.world-toggle-inline {
  font-size: 12px;
}

.world-jump {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.world-jump > label {
  color: #91a2a9;
  font-size: 11px;
}

.world-jump-row {
  display: flex;
  gap: 6px;
}

.world-jump-row input {
  background: #0b1115;
  border: 1px solid #35454e;
  border-radius: 5px;
  color: #edf4f4;
  font-size: 12px;
  height: 34px;
  min-width: 0;
  padding: 0 8px;
  width: 100%;
}

.world-jump-row button {
  flex-shrink: 0;
  white-space: nowrap;
}

.world-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.world-canvas-wrap {
  background: #05070a;
  border: 1px solid #26313a;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.world-canvas-wrap canvas {
  display: block;
  height: auto;
  width: 100%;
}

.world-canvas-wrap #world-canvas {
  cursor: crosshair;
  image-rendering: pixelated;
  touch-action: none;
}

.world-canvas-wrap #world-overlay {
  inset: 0;
  pointer-events: none;
  position: absolute;
}

/* 一张瓦片都还没到时的加载提示：**只有一个小转圈，不写文字** */
.world-loading {
  border: 2px solid rgba(120, 220, 255, 0.25);
  border-radius: 50%;
  border-top-color: rgba(120, 220, 255, 0.9);
  height: 22px;
  left: 50%;
  margin: -11px 0 0 -11px;
  position: absolute;
  top: 50%;
  width: 22px;
  animation: world-spin 0.9s linear infinite;
}

@keyframes world-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .world-loading { animation-duration: 2.4s; }
}

/* 后台预渲染进度：画框最上面一条 2px 细线（**不写文字**，具体数字在画框 title 里） */
.world-tile-progress {
  background: rgba(255, 255, 255, 0.06);
  height: 2px;
  inset: 0 0 auto 0;
  overflow: hidden;
  position: absolute;
  z-index: 4;
}

.world-tile-progress span {
  background: linear-gradient(90deg, #4ea57f, #79d2aa);
  display: block;
  height: 100%;
  transition: width 0.25s ease-out;
  width: 0;
}

/* 诊断（本地缓存/在飞请求/服务端内存/预渲染进度）：只在 ?debug=1 时出现，
   平时这些数字躺在画框的 title 悬停提示里 —— 界面正文一个多余的字都不放 */
.world-debug {
  background: rgba(6, 10, 13, 0.86);
  border-top: 1px solid #26313a;
  bottom: 0;
  color: #8c9aa6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  inset: auto 0 0 0;
  line-height: 1.5;
  margin: 0;
  padding: 3px 8px;
  position: absolute;
  z-index: 5;
  word-break: break-all;
}

/* 画框下方的导出工具带：整图 / 选区两个分组，宽屏左右排、窄屏堆叠。
   按钮文字可能带上尺寸而变长，统一允许换行、不许顶出容器。 */
.world-export-panel {
  background: #0b1115;
  border: 1px solid #26313a;
  border-radius: 10px;
  display: grid;
  gap: 16px;
  grid-template-columns: 230px minmax(0, 1fr);
  padding: 14px 16px;
}

@media (max-width: 960px) {
  .world-export-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

.world-export-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* 宽屏下两组之间留一条竖向分隔线 */
@media (min-width: 961px) {
  .world-export-full {
    border-right: 1px solid #26313a;
    padding-right: 16px;
  }
}

.world-export-title {
  color: #7d8b96;
  font-size: 11px;
  letter-spacing: 0.06em;
  margin: 0 0 2px;
}

.world-export-group .action-button {
  line-height: 1.35;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 8px 12px;
  text-align: center;
  white-space: normal;
  width: 100%;
}

/* 导出 2D 图期间：进度条**居中在画框里**（原来贴底边），整块画框也被冻住 ——
   见下面 .is-exporting 的压暗层。 */
.world-frame-progress {
  background: linear-gradient(180deg, #0e161b, #0a1015);
  border: 1px solid #2b3a42;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  left: 50%;
  padding: 12px 14px 14px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, 74%);
  z-index: 6;
}

.world-frame-progress-head {
  align-items: center;
  color: #b9c8cd;
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.world-frame-progress-head strong {
  color: #d7e6e2;
  font-variant-numeric: tabular-nums;
}

.world-frame-progress-track {
  background: #0b1115;
  border: 1px solid #26313a;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.world-frame-progress-track span {
  background: linear-gradient(90deg, #4ea57f, #79d2aa);
  display: block;
  height: 100%;
  transition: width 0.18s ease-out;
  width: 0;
}

/* 导出 2D 图期间画框**被冻住**：不能拖动/缩放，也不再请求新瓦片（这段 CPU 全让给导出）。
   压暗一层 + 吃掉指针事件（双保险：客户端那边也把交互关了），进度条居中浮在上面。 */
.world-canvas-wrap.is-exporting {
  cursor: progress;
}

.world-canvas-wrap.is-exporting::after {
  background: rgba(3, 6, 9, 0.58);
  content: "";
  inset: 0;
  position: absolute;
  z-index: 5;
}

/* 视口信息行已经整个去掉（它会顶动画框、PC 上也干扰）；坐标看画框里的提示框就行。 */

.world-legend {
  color: #8c9aa6;
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  gap: 8px 16px;
}

.world-legend-item {
  align-items: center;
  display: inline-flex;
  gap: 0;
  white-space: normal;
}

.world-legend-swatch {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  display: inline-block;
  height: 10px;
  margin-right: 5px;
  vertical-align: -1px;
  width: 10px;
}

.world-legend-air {
  background: #171d23;
}

.world-legend-unknown {
  background: #0a0d10;
}

.world-legend-tip {
  color: #8c9aa6;
  flex-basis: 100%;
}

.section-heading-sub {
  margin-top: 20px;
}

/* 游戏规则：表格形式（表头 + 每行一条，左名称右设置），布尔项用胶囊开关 */
.world-rules {
  border: 1px solid #26313a;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.world-rules-head {
  align-items: center;
  background: #0e151a;
  color: #7d8b96;
  display: flex;
  font-size: 11px;
  justify-content: space-between;
  letter-spacing: 0.04em;
  padding: 8px 12px;
}

.world-rule {
  align-items: center;
  border-top: 1px solid #1d272e;
  color: #c4d0d6;
  display: flex;
  font-size: 12px;
  gap: 12px;
  justify-content: space-between;
  padding: 8px 12px;
}

/* 胶囊开关：原生 checkbox 透明盖在轨道上，轨道/圆点/开关文字都是纯样式 */
.world-pill {
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  position: relative;
}

.world-pill input {
  cursor: pointer;
  height: 100%;
  inset: 0;
  margin: 0;
  opacity: 0;
  position: absolute;
  width: 100%;
  z-index: 1;
}

.world-pill-track {
  align-items: center;
  background: #26313a;
  border: 1px solid #35454e;
  border-radius: 999px;
  color: #9fb0b8;
  display: inline-flex;
  font-size: 11px;
  height: 24px;
  justify-content: flex-end;
  padding: 0 10px;
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  width: 54px;
}

.world-pill-track::before {
  background: #8fa0a8;
  border-radius: 50%;
  content: "";
  height: 18px;
  left: 2px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: left 0.18s ease, background 0.18s ease;
  width: 18px;
}

.world-pill-label-on {
  display: none;
}

.world-pill input:checked ~ .world-pill-track {
  background: #2f7d5b;
  border-color: #3c9a72;
  color: #e9f7ef;
  justify-content: flex-start;
}

.world-pill input:checked ~ .world-pill-track::before {
  background: #e9f7ef;
  left: 33px;
}

.world-pill input:checked ~ .world-pill-track .world-pill-label-on {
  display: inline;
}

.world-pill input:checked ~ .world-pill-track .world-pill-label-off {
  display: none;
}

.world-pill input:focus-visible ~ .world-pill-track {
  box-shadow: 0 0 0 2px rgba(114, 205, 166, 0.28);
}

.world-rule-number {
  background: #0b1115;
  border: 1px solid #35454e;
  border-radius: 5px;
  color: #edf4f4;
  font-size: 12px;
  height: 32px;
  padding: 0 8px;
  width: 96px;
}

.world-spawn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 重生点那一行要占满整行，否则三个坐标输入框在网格里会被挤成一小列 */
.world-spawn-field {
  grid-column: 1 / -1;
}

.world-spawn-row input {
  background: #0b1115;
  border: 1px solid #35454e;
  border-radius: 5px;
  color: #edf4f4;
  font-size: 12px;
  height: 36px;
  padding: 0 8px;
  width: 90px;
}

.convert-toolbar-copy code {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  font-size: 12px;
  padding: 1px 5px;
}

/* ---------------------------------------------------------------- 选范围导出（2D 图） */

/* 四个坐标框：宽屏一行四个，窄屏折成 2×2 */
.world-region-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 960px) {
  .world-region-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.world-region-grid .field label {
  margin-bottom: 4px;
}

.world-region-grid input {
  background: #0b1115;
  border: 1px solid #35454e;
  border-radius: 5px;
  color: #edf4f4;
  font-size: 12px;
  height: 34px;
  padding: 0 8px;
  width: 100%;
}

.world-region-grid input:focus {
  border-color: #72cda6;
  box-shadow: 0 0 0 2px rgba(114, 205, 166, 0.12);
  outline: none;
}

/* 主动作：导出选区 / 下载结果 等宽并排，只剩一个时自动占满 */
.world-region-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.world-region-primary .action-button {
  flex: 1 1 160px;
  width: auto;
}

/* 辅助操作（选中当前画框 / 定位 / 清空）：小号弱化按钮，和主动作拉开层级。
   flex-basis 0 + min-width:0 让三个按钮严格等长；要覆盖组级 width:100%，否则会各占一行 */
.world-region-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.world-region-tools .action-button {
  background: transparent;
  border-color: #2c3b44;
  color: #9fb0b8;
  flex: 1 1 0;
  font-size: 11px;
  min-height: 30px;
  min-width: 0;
  padding: 5px 10px;
  width: auto;
}

.world-region-tools .action-button:hover:not(:disabled) {
  border-color: #4ea57f;
  color: #cfe4da;
}

/* 「选区 32 × 32 方块 = 1024 像素」这行跟着输入框走，超上限时变红 */
.world-region-note {
  color: #8c9aa6;
  font-size: 11px;
  line-height: 1.5;
  margin: 0;
}

.world-region-note.is-error {
  color: #efb4b4;
}

/* 选区导出的就地反馈，贴紧本组、不要默认的大边距 */
#world-region-feedback {
  font-size: 12px;
  margin: 0;
  padding: 7px 10px;
}

/* ---------------------------------------------------------------- 后台「滞留存档」 */

.lingering-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

/* 合计那行与下面的列表之间要留出间距（.admin-summary 原本只有上边距） */
#lingering-summary {
  margin: 6px 0 16px;
}

.lingering-note {
  color: #6f7d88;
  font-size: 12px;
  margin: 0 0 14px;
}

/* 每行：勾选框 + 存档信息 + 操作按钮 */
.lingering-item {
  align-items: center;
  background: #11171d;
  border: 1px solid #26313a;
  border-radius: 10px;
  display: grid;
  gap: 14px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 13px 16px;
}

.lingering-check {
  height: 16px;
  width: 16px;
}

.lingering-info {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.lingering-name {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 15px;
  font-weight: 650;
  gap: 9px;
  margin: 0;
  overflow-wrap: anywhere;
}

.lingering-meta {
  color: #9eacb8;
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 14px;
  overflow-wrap: anywhere;
}

.lingering-badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 10px;
}

.lingering-badge.is-world {
  background: rgba(101, 193, 140, 0.16);
  color: #9edcb8;
}

.lingering-badge.is-convert {
  background: rgba(120, 170, 230, 0.16);
  color: #a8c8ee;
}

