html {
  scroll-snap-type: none;
}

.redactor-page {
  --lab-bg: #07110f;
  --lab-panel: #0a1714;
  --lab-panel-strong: #0d1c18;
  --lab-ink: #e8eee9;
  --lab-muted: #81918a;
  --lab-accent: #d9ff57;
  --lab-orange: #ff8b5e;
  --lab-line: rgba(217, 255, 87, 0.17);
  min-height: 100vh;
  color: var(--lab-ink);
  background:
    radial-gradient(circle at 72% 13%, rgba(217, 255, 87, 0.055), transparent 28%),
    linear-gradient(90deg, transparent 49.95%, rgba(217, 255, 87, 0.025) 50%, transparent 50.05%),
    var(--lab-bg);
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
}

.redactor-page [hidden] { display: none !important; }

.redactor-page::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(217, 255, 87, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 255, 87, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, #000, transparent 82%);
}

.redactor-page .tool-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0 46px;
  border-bottom: 1px solid rgba(232, 238, 233, 0.12);
  background: rgba(7, 17, 15, 0.84);
  backdrop-filter: blur(16px);
}

.redactor-page .tool-header::after {
  position: absolute;
  right: 46px;
  bottom: -1px;
  width: 84px;
  height: 1px;
  content: "";
  background: var(--lab-accent);
  box-shadow: 0 0 14px rgba(217, 255, 87, 0.55);
}

.redactor-page .brand { font-weight: 500; }
.redactor-page .brand-slash { color: var(--lab-accent); }

.tool-header-meta {
  display: flex;
  align-items: center;
  gap: 30px;
  color: rgba(129, 145, 138, 0.76);
  font: 500 9px/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.12em;
}

.tool-header-meta a { color: rgba(232, 238, 233, 0.76); }
.tool-header-meta b { margin-left: 6px; color: var(--lab-accent); }

.redactor-page .tool-main {
  width: min(1560px, calc(100vw - 80px));
  margin: 0 auto;
  padding: 82px 0 100px;
}

.tool-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  align-items: end;
  gap: 8vw;
  margin-bottom: 48px;
}

.tool-kicker,
.empty-index {
  margin: 0 0 20px;
  color: rgba(217, 255, 87, 0.67);
  font: 500 9px/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.18em;
}

.tool-intro h1 {
  margin: 0;
  font-size: clamp(50px, 6.4vw, 96px);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.tool-intro h1 em {
  color: var(--lab-accent);
  font-style: normal;
}

.intro-copy { padding-bottom: 8px; }
.intro-copy > p {
  max-width: 540px;
  margin: 0;
  color: var(--lab-muted);
  font-size: 14px;
  line-height: 1.9;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 25px;
  color: rgba(217, 255, 87, 0.58);
  font: 500 9px/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.12em;
}

.local-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lab-accent);
  box-shadow: 0 0 13px rgba(217, 255, 87, 0.76);
  animation: status-pulse 2.2s ease-in-out infinite;
}

.safety-note {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px 18px;
  color: rgba(232, 238, 233, 0.67);
  border: 1px solid rgba(255, 139, 94, 0.19);
  border-left: 3px solid var(--lab-orange);
  background: rgba(255, 139, 94, 0.035);
}

.safety-note span {
  color: var(--lab-orange);
  font: 600 9px/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.12em;
}

.safety-note p { margin: 0; font-size: 11px; line-height: 1.7; }

.redactor-workspace {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  min-height: 820px;
  overflow: hidden;
  border: 1px solid rgba(217, 255, 87, 0.2);
  background: rgba(8, 20, 17, 0.92);
  box-shadow: 0 44px 130px rgba(0, 0, 0, 0.35);
}

.control-panel {
  display: flex;
  flex-direction: column;
  max-height: 920px;
  overflow-y: auto;
  padding: 28px;
  border-right: 1px solid rgba(217, 255, 87, 0.16);
  background: rgba(8, 20, 17, 0.96);
  scrollbar-color: rgba(217, 255, 87, 0.25) transparent;
  scrollbar-width: thin;
}

.panel-heading,
.group-title,
.preview-header,
.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-heading,
.group-title {
  color: rgba(129, 145, 138, 0.72);
  font: 500 9px/1 "IBM Plex Mono", monospace;
  letter-spacing: 0.13em;
}

.panel-heading { margin-bottom: 18px; }
.text-button,
.replace-button,
.delete-region {
  padding: 0;
  color: rgba(217, 255, 87, 0.8);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}

button:disabled { opacity: 0.28; cursor: default; }

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 184px;
  padding: 22px;
  border: 1px dashed rgba(217, 255, 87, 0.36);
  background:
    linear-gradient(rgba(217, 255, 87, 0.025), rgba(217, 255, 87, 0.008)),
    repeating-linear-gradient(-45deg, transparent 0 13px, rgba(217, 255, 87, 0.018) 13px 14px);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.25s ease, transform 0.25s ease, background 0.25s ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--lab-accent);
  background-color: rgba(217, 255, 87, 0.045);
  transform: translateY(-2px);
}

.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.upload-mark { position: relative; display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 13px; }
.upload-mark i { position: absolute; inset: 0; border: 1px solid rgba(217, 255, 87, 0.4); transform: rotate(45deg); }
.upload-mark b { color: var(--lab-accent); font: 300 24px/1 "IBM Plex Mono", monospace; }
.drop-zone strong { font-size: 13px; font-weight: 500; }
.drop-zone small { margin-top: 7px; color: var(--lab-muted); font: 400 9px/1 "IBM Plex Mono", monospace; }

.file-summary {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 13px;
  border: 1px solid var(--lab-line);
  background: rgba(217, 255, 87, 0.025);
}

.file-summary:not([hidden]) { display: grid; }
.file-index { display: grid; place-items: center; width: 42px; height: 42px; color: var(--lab-accent); border: 1px solid var(--lab-line); font: 600 10px/1 "IBM Plex Mono", monospace; }
.file-summary strong,
.file-summary small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-summary strong { max-width: 210px; font-size: 11px; font-weight: 500; }
.file-summary small { max-width: 210px; margin-top: 5px; color: var(--lab-muted); font: 400 8px/1 "IBM Plex Mono", monospace; }

.settings { display: grid; min-width: 0; margin: 0; padding: 0; border: 0; }
.settings:disabled { opacity: 0.38; }
.setting-group { padding: 24px 0; border-bottom: 1px solid rgba(217, 255, 87, 0.1); }
.group-title { margin-bottom: 15px; }
.group-title small { font: inherit; letter-spacing: 0.02em; }

.preset-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--lab-ink);
  border: 1px solid rgba(217, 255, 87, 0.2);
  background: rgba(217, 255, 87, 0.025);
  cursor: pointer;
  font-size: 11px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.preset-button:hover { border-color: var(--lab-accent); background: rgba(217, 255, 87, 0.06); }
.preset-button b { margin-right: 8px; color: var(--lab-accent); font: 600 10px/1 "IBM Plex Mono", monospace; }
.preset-button i { color: var(--lab-accent); font: normal 17px/1 "IBM Plex Mono", monospace; }
.setting-tip { margin: 9px 0 0; color: rgba(129, 145, 138, 0.68); font-size: 9px; line-height: 1.6; }

.region-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.region-chip {
  padding: 7px 9px;
  color: rgba(232, 238, 233, 0.6);
  border: 1px solid rgba(129, 145, 138, 0.2);
  background: transparent;
  cursor: pointer;
  font: 500 8px/1 "IBM Plex Mono", monospace;
}
.region-chip.is-active { color: #10150c; border-color: var(--lab-accent); background: var(--lab-accent); }

.coordinate-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 12px; }
.coordinate-grid:not([hidden]) { display: grid; }
.coordinate-grid label { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; border: 1px solid rgba(129, 145, 138, 0.2); }
.coordinate-grid span { color: var(--lab-accent); text-align: center; font: 500 8px/1 "IBM Plex Mono", monospace; }
.coordinate-grid input {
  min-width: 0;
  width: 100%;
  height: 34px;
  padding: 0 5px;
  color: var(--lab-ink);
  border: 0;
  outline: 0;
  background: rgba(3, 9, 7, 0.5);
  font: 400 10px/1 "IBM Plex Mono", monospace;
}
.delete-region { margin-top: 12px; color: rgba(255, 139, 94, 0.75); }

.mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.mode-switch label { cursor: pointer; }
.mode-switch input { position: absolute; opacity: 0; }
.mode-switch span {
  display: grid;
  gap: 4px;
  min-height: 52px;
  padding: 10px 9px;
  color: rgba(232, 238, 233, 0.57);
  border: 1px solid rgba(129, 145, 138, 0.2);
  font-size: 11px;
  transition: 0.2s ease;
}
.mode-switch small { color: var(--lab-muted); font: 400 8px/1 "IBM Plex Mono", monospace; }
.mode-switch input:checked + span { color: var(--lab-ink); border-color: var(--lab-accent); background: rgba(217, 255, 87, 0.055); }
.mode-switch input:checked + span small { color: var(--lab-accent); }

.test-text-field > span:first-child small { color: var(--lab-orange); font-size: 8px; font-weight: 400; }
.test-text-field input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  color: var(--lab-ink);
  border: 1px solid rgba(255, 139, 94, 0.28);
  outline: 0;
  background: rgba(255, 139, 94, 0.035);
  font: 500 10px/1 "IBM Plex Mono", monospace;
}
.test-text-field input:focus { border-color: var(--lab-orange); }

.field { display: grid; gap: 9px; margin-top: 14px; }
.field > span:first-child { display: flex; justify-content: space-between; color: rgba(232, 238, 233, 0.62); font-size: 10px; }
.field output { color: var(--lab-accent); font: 500 9px/1 "IBM Plex Mono", monospace; }
.color-field { grid-template-columns: 1fr auto; align-items: center; }
.color-control { display: flex; align-items: center; gap: 9px; }
.color-control input { width: 28px; height: 28px; padding: 0; border: 1px solid rgba(217, 255, 87, 0.2); background: transparent; cursor: pointer; }
.color-control code { color: var(--lab-muted); font: 400 9px/1 "IBM Plex Mono", monospace; }

input[type="range"] { width: 100%; height: 3px; margin: 3px 0; accent-color: var(--lab-accent); cursor: pointer; }
.size-options,
.export-options { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; }
.export-options { margin-top: 15px; }
.compact-field { margin-top: 0; }
.compact-field select,
.dimension-input {
  width: 100%;
  height: 38px;
  color: var(--lab-ink);
  border: 1px solid rgba(129, 145, 138, 0.22);
  outline: 0;
  background: #0a1512;
  font: 400 10px/1 "IBM Plex Mono", monospace;
}
.compact-field select { padding: 0 10px; }
.dimension-input { display: grid; grid-template-columns: minmax(0, 1fr) 28px; align-items: center; }
.dimension-input input {
  min-width: 0;
  width: 100%;
  height: 36px;
  padding: 0 0 0 10px;
  color: var(--lab-ink);
  border: 0;
  outline: 0;
  background: transparent;
  font: 400 10px/1 "IBM Plex Mono", monospace;
}
.dimension-input b { color: var(--lab-muted); font: 400 8px/1 "IBM Plex Mono", monospace; }
.export-size-summary { margin: 9px 0 0; color: rgba(217, 255, 87, 0.62); font: 500 8px/1.5 "IBM Plex Mono", monospace; }
.fixed-mark { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: rgba(129, 145, 138, 0.75); font-size: 9px; }
.fixed-mark i { display: grid; place-items: center; width: 18px; height: 18px; color: #10150c; border-radius: 50%; background: var(--lab-accent); font: normal 10px/1 "IBM Plex Mono", monospace; }

.export-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  margin-top: auto;
  padding: 0 19px;
  color: #11170d;
  border: 0;
  background: var(--lab-accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.export-button:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(217, 255, 87, 0.13); }
.export-button span { display: grid; gap: 5px; }
.export-button small { font: 500 7px/1 "IBM Plex Mono", monospace; letter-spacing: 0.11em; }
.export-button b { font: 400 24px/1 "IBM Plex Mono", monospace; }

.preview-panel { display: flex; min-width: 0; flex-direction: column; background: #050b09; }
.preview-header { min-height: 70px; padding: 0 24px; border-bottom: 1px solid rgba(217, 255, 87, 0.12); }
.preview-header > div:first-child { display: grid; gap: 7px; }
.preview-header span,
.preview-footer { color: rgba(129, 145, 138, 0.76); font: 500 9px/1 "IBM Plex Mono", monospace; letter-spacing: 0.1em; }
.preview-header small { max-width: 420px; overflow: hidden; color: rgba(232, 238, 233, 0.65); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.canvas-guide { display: flex; gap: 20px; }
.canvas-guide span::before { margin-right: 7px; color: var(--lab-accent); content: "·"; }

.canvas-stage {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 680px;
  place-items: center;
  overflow: hidden;
  padding: 38px;
  background:
    linear-gradient(rgba(217, 255, 87, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 255, 87, 0.035) 1px, transparent 1px),
    radial-gradient(circle at center, #0b1612, #050b09 68%);
  background-size: 32px 32px, 32px 32px, auto;
}

.canvas-stage::before,
.canvas-stage::after { position: absolute; pointer-events: none; content: ""; }
.canvas-stage::before { inset: 20px; border: 1px solid rgba(217, 255, 87, 0.07); }
.canvas-stage::after { top: 20px; left: 50%; width: 1px; height: 16px; background: var(--lab-accent); }

.canvas-stage canvas {
  position: relative;
  z-index: 2;
  display: none;
  max-width: 100%;
  max-height: 680px;
  outline: none;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(232, 238, 233, 0.14);
  touch-action: none;
  user-select: none;
}
.canvas-stage canvas:focus-visible { box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52), 0 0 0 2px var(--lab-accent); }
.canvas-stage.has-image canvas { display: block; }

.empty-preview { display: grid; position: relative; z-index: 1; place-items: center; text-align: center; }
.canvas-stage.has-image .empty-preview { display: none; }
.scanner-plate { position: relative; width: 260px; height: 150px; margin-bottom: 30px; border: 1px solid rgba(129, 145, 138, 0.25); background: rgba(217, 255, 87, 0.015); }
.scanner-plate i { position: absolute; width: 24px; height: 24px; border-color: var(--lab-accent); border-style: solid; }
.scanner-plate i:nth-child(1) { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.scanner-plate i:nth-child(2) { top: -1px; right: -1px; border-width: 2px 2px 0 0; }
.scanner-plate i:nth-child(3) { right: -1px; bottom: -1px; border-width: 0 2px 2px 0; }
.scanner-plate i:nth-child(4) { bottom: -1px; left: -1px; border-width: 0 0 2px 2px; }
.scanner-plate span { position: absolute; top: 52%; left: 11%; width: 78%; height: 30px; border: 1px solid rgba(255, 139, 94, 0.5); background: rgba(255, 139, 94, 0.055); transform: translateY(-50%); }
.scanner-plate span::after { position: absolute; top: -38px; left: 50%; width: 1px; height: 106px; content: ""; background: linear-gradient(transparent, var(--lab-accent), transparent); box-shadow: 0 0 11px rgba(217, 255, 87, 0.5); animation: scanner 3s ease-in-out infinite; }
.empty-preview strong { font-size: 17px; font-weight: 400; }
.empty-preview > p:last-child { margin: 9px 0 0; color: var(--lab-muted); font-size: 10px; }

.preview-footer { min-height: 48px; padding: 0 24px; border-top: 1px solid rgba(217, 255, 87, 0.1); letter-spacing: 0.05em; }
.preview-footer span:nth-child(2) { color: rgba(217, 255, 87, 0.58); }

.tool-notes { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 18px; border: 1px solid rgba(217, 255, 87, 0.12); }
.tool-notes article { display: grid; grid-template-columns: 48px 1fr; padding: 24px; border-right: 1px solid rgba(217, 255, 87, 0.1); }
.tool-notes article:last-child { border-right: 0; }
.tool-notes span { grid-row: span 2; color: var(--lab-accent); font: 500 10px/1 "IBM Plex Mono", monospace; }
.tool-notes h2 { margin: 0; font-size: 13px; font-weight: 500; }
.tool-notes p { margin: 7px 0 0; color: var(--lab-muted); font-size: 10px; line-height: 1.7; }

.tool-toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 40px));
  padding: 14px 18px;
  color: #11170d;
  background: var(--lab-accent);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.38);
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.tool-toast.is-visible { opacity: 1; transform: translateY(0); }

@keyframes scanner { 0%, 100% { transform: translateX(-90px); opacity: 0.25; } 50% { transform: translateX(90px); opacity: 1; } }
@keyframes status-pulse { 50% { opacity: 0.45; box-shadow: 0 0 4px rgba(217, 255, 87, 0.45); } }

@media (max-width: 1120px) {
  .redactor-page .tool-main { width: min(100% - 40px, 1000px); }
  .redactor-workspace { grid-template-columns: 350px minmax(0, 1fr); }
  .control-panel { padding: 22px; }
  .canvas-guide { display: none; }
}

@media (max-width: 820px) {
  .redactor-page .tool-header { min-height: 66px; padding: 0 20px; }
  .tool-header-meta > span { display: none; }
  .redactor-page .tool-main { width: min(100% - 24px, 680px); padding: 58px 0 70px; }
  .tool-intro { grid-template-columns: 1fr; gap: 28px; }
  .tool-intro h1 { font-size: clamp(46px, 15vw, 74px); }
  .safety-note { grid-template-columns: 1fr; gap: 7px; }
  .redactor-workspace { grid-template-columns: 1fr; }
  .control-panel { max-height: none; border-right: 0; border-bottom: 1px solid var(--lab-line); }
  .canvas-stage { min-height: 480px; padding: 28px; }
  .canvas-stage canvas { max-height: 520px; }
  .tool-notes { grid-template-columns: 1fr; }
  .tool-notes article { border-right: 0; border-bottom: 1px solid rgba(217, 255, 87, 0.1); }
  .tool-notes article:last-child { border-bottom: 0; }
}

@media (max-width: 520px) {
  .redactor-page .brand-cn,
  .redactor-page .brand-slash { display: none; }
  .tool-header-meta { font-size: 8px; }
  .preview-header { padding: 0 16px; }
  .preview-footer { display: grid; grid-template-columns: 1fr 1fr; padding: 10px 16px; gap: 6px; }
  .preview-footer span:last-child { grid-column: 1 / -1; }
  .canvas-stage { min-height: 360px; padding: 20px; }
  .coordinate-grid { grid-template-columns: repeat(2, 1fr); }
  .mode-switch { grid-template-columns: 1fr; }
  .scanner-plate { width: 220px; height: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
