:root {
  color-scheme: dark;
  --bg: #111414;
  --panel: #1b1f1f;
  --line: #323938;
  --text: #e9edeb;
  --muted: #a2aeab;
  --quiet: #87928f;
  --accent: #82ebcf;
  --strong: #a4f3db;
  --mono: "Cascadia Mono", Consolas, monospace;
  font-family: Inter, "Segoe UI", "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.sprite, .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shell { width: min(1200px, calc(100% - 80px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid #2c3231; background: #171a1a; }
.masthead-inner { min-height: 68px; padding-block: 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand, .brand-text { display: flex; }
.brand { min-width: 0; align-items: center; gap: 12px; }
.brand-mark { display: block; flex: 0 0 auto; }
.brand-text { flex-direction: column; gap: 3px; }
.brand-text strong { font-size: 15px; line-height: 1.3; }
.brand-text span { font-size: 11px; line-height: 1.35; color: var(--muted); }
.local-indicator { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.local-indicator > span, .preview-dot { width: 6px; height: 6px; flex: 0 0 auto; background: var(--accent); }

.page-title { padding-top: 29px; margin-bottom: 21px; }
.kicker { display: flex; align-items: center; gap: 9px; color: var(--accent); font: 12px/1.4 var(--mono); }
.kicker > span { width: 19px; height: 1px; background: var(--accent); }
h1 { font-size: 42px; line-height: 1.25; margin: 8px 0 0; font-weight: 700; }

.steps {
  margin: 0 0 17px;
  padding: 0 0 13px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 17px;
  list-style: none;
  border-bottom: 1px solid #2b3331;
}
.steps li { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--quiet); }
.steps li[data-state="current"] { color: var(--accent); }
.steps li[data-state="done"] { color: var(--muted); }
.step-number {
  display: grid;
  place-items: center;
  min-width: 27px;
  height: 22px;
  font: 11px/1 var(--mono);
  background: #1c2121;
  border: 1px solid #303937;
  border-radius: 3px;
}
.steps [data-state="current"] .step-number { background: #28473e; border-color: #4c7868; }
.steps .icon { margin-left: 6px; width: 13px; height: 13px; color: #667571; }

.workbench { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr); align-items: start; gap: 18px; }
.tool { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; }
.tool-heading {
  min-height: 62px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.heading-label { display: flex; align-items: center; gap: 9px; }
.heading-label .icon { color: var(--accent); }
h2 { margin: 0; font-size: 16px; font-weight: 650; line-height: 1.25; }
.format-tag { color: var(--muted); font: 12px/1.3 var(--mono); white-space: nowrap; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #44524e;
  border-radius: 4px;
  min-height: 38px;
  padding: 0 12px;
  background: #252c2b;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.button .icon { width: 15px; height: 15px; }
.button:hover:not(:disabled) { background: #313f3b; border-color: #698178; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .46; }
.primary-button { background: var(--accent); color: #142723; border-color: var(--accent); min-width: 120px; }
.primary-button:hover:not(:disabled) { background: var(--strong); border-color: var(--strong); }
.confirm-button[data-editing="true"] { border-color: #547c6e; color: var(--accent); background: #223630; }

.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: clamp(256px, 41vh, 380px);
  container-type: size;
  background-color: #151a19;
  background-image: linear-gradient(#a1c4b20d 1px, transparent 1px), linear-gradient(90deg, #a1c4b20d 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: center;
}
.crop-stage { touch-action: none; user-select: none; }
.crop-stage:focus-visible { outline-offset: -3px; }
.crop-stage[data-ready="true"] { cursor: grab; }
.crop-stage.dragging { cursor: grabbing; }
#source { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crop-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(calc(100cqw - 36px), calc(100cqh - 58px), 322px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.crop-shade { position: absolute; inset: 0; box-shadow: 0 0 0 130vmax #080e0c65; border: 1px solid #b1f9e075; }
.thirds {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(#e1fff4a1, #e1fff4a1) 33.333% 0 / 1px 100% no-repeat,
    linear-gradient(#e1fff4a1, #e1fff4a1) 66.666% 0 / 1px 100% no-repeat,
    linear-gradient(#e1fff4a1, #e1fff4a1) 0 33.333% / 100% 1px no-repeat,
    linear-gradient(#e1fff4a1, #e1fff4a1) 0 66.666% / 100% 1px no-repeat;
}
.crop-stage[data-editing="false"] .thirds { opacity: .44; }
.corner { position: absolute; width: 14px; height: 14px; border: solid var(--accent); border-width: 0; pointer-events: none; }
.corner.tl { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.corner.tr { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 2px; border-left-width: 2px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 2px; border-right-width: 2px; }
.stage-label {
  position: absolute;
  left: 12px;
  bottom: 5px;
  padding: 3px 6px;
  background: #191f1e;
  border: 1px solid #384440;
  border-radius: 3px;
  color: #bdcbc5;
  font: 11px/1 var(--mono);
  pointer-events: none;
}
.empty-import {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 15px 21px;
  border: 1px dashed #58766c;
  border-radius: 4px;
  background: #1d2a27;
  color: var(--accent);
  font-size: 14px;
  white-space: nowrap;
}
.drop-indicator {
  position: absolute;
  inset: 6px;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: #132c27ee;
  border: 1px dashed var(--accent);
  border-radius: 4px;
  color: var(--accent);
  pointer-events: none;
  font-size: 14px;
  font-weight: 650;
}
.drop-indicator .icon, .empty-import .icon { width: 26px; height: 26px; }
.drag-active .drop-indicator { display: grid; }

.preview-assembly { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; }
.result-frame { position: relative; width: min(calc(100cqw - 48px), calc(100cqh - 78px), 278px); aspect-ratio: 1; background: #252d2b; }
#preview { display: block; width: 100%; height: 100%; }
.result-frame .corner { width: 11px; height: 11px; border-color: #80968d; }
.result-frame .tl, .result-frame .tr { top: -5px; border-top-width: 1px; }
.result-frame .bl, .result-frame .br { bottom: -5px; border-bottom-width: 1px; }
.result-frame .tl, .result-frame .bl { left: -5px; border-left-width: 1px; }
.result-frame .tr, .result-frame .br { right: -5px; border-right-width: 1px; }
.result-frame[data-state="empty"] canvas { visibility: hidden; }
.no-result { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.no-result .icon { width: 23px; height: 23px; }
.preview-caption { min-height: 20px; display: flex; align-items: center; gap: 7px; color: #c4d3ce; font-size: 12px; }
.preview-dot { background: #7daca0; }

.tool-controls, .style-controls { height: 62px; padding: 9px 16px; border: 0; border-top: 1px solid var(--line); }
.tool-controls { display: flex; align-items: center; gap: 12px; }
.zoom-tools { display: grid; grid-template-columns: auto minmax(24px, 1fr) auto 43px; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.tool-button {
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #394442;
  border-radius: 4px;
  background: #242b2a;
  color: #d3dfdb;
  padding: 0;
}
.tool-button:hover:not(:disabled) { background: #303e3a; color: var(--accent); border-color: #58756b; }
.tool-button:disabled { opacity: .47; }
.range-slider {
  appearance: none;
  margin: 0;
  width: 100%;
  min-width: 0;
  height: 36px;
  background: transparent;
  cursor: ew-resize;
  --track: linear-gradient(to right, var(--accent) var(--progress, 0%), #44514e var(--progress, 0%));
}
.range-slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--track); }
.range-slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--track); }
.range-slider::-webkit-slider-thumb {
  appearance: none;
  margin-top: -5px;
  width: 14px;
  height: 14px;
  border: 1px solid #c4f5e6;
  border-radius: 50%;
  background: var(--accent);
}
.range-slider::-moz-range-thumb { width: 12px; height: 12px; border: 1px solid #c4f5e6; border-radius: 50%; background: var(--accent); }
.range-slider:disabled { opacity: .45; cursor: not-allowed; }
#zoom-value { text-align: right; color: var(--muted); font: 12px/1 var(--mono); }
.tool-divider { height: 24px; border-left: 1px solid #394442; }

.style-controls { min-width: 0; margin: 0; display: grid; align-items: center; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.style-option { min-width: 0; position: relative; }
.style-option input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; }
.style-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 40px;
  background: #222827;
  color: #c7d1ce;
  border: 1px solid #384441;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.style-option input:not(:disabled):focus-visible + .style-label { outline: 2px solid var(--accent); outline-offset: 2px; }
.style-option:hover input:not(:disabled) + .style-label { border-color: #69867b; }
.style-option input:checked + .style-label { color: var(--strong); background: #253c36; border-color: #588577; }
.style-option input:disabled + .style-label { opacity: .55; cursor: not-allowed; }
.style-option input { cursor: pointer; }
.style-option input:disabled { cursor: not-allowed; }
.style-label i {
  width: 11px;
  height: 11px;
  margin-left: auto;
  flex: 0 0 auto;
  border: 1px solid #72867f;
  border-radius: 50%;
}
.style-option input:checked + .style-label i { border: 3px solid #99eed6; }
.style-symbol { width: 21px; height: 21px; flex: 0 0 auto; fill: currentColor; fill-rule: evenodd; }

.tone-controls { min-width: 0; margin: 0; padding: 7px 16px 12px; border: 0; border-top: 1px solid var(--line); }
.tone-heading, .tone-reset { display: flex; align-items: center; }
.tone-heading { justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 650; }
.tone-reset { gap: 5px; min-height: 32px; padding: 0 2px; background: transparent; border: 0; color: var(--accent); font-size: 12px; }
.tone-reset .icon { width: 13px; height: 13px; }
.tone-reset:hover:not(:disabled) { text-decoration: underline; }
.tone-reset:disabled { color: var(--quiet); }
.tone-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 44px; align-items: center; gap: 10px; font-size: 13px; }
.tone-row output { text-align: right; color: var(--muted); font: 12px/1 var(--mono); }
#icon-gray { --track: linear-gradient(to right, #353938, #fff); }
.tone-hint { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.tool-footer { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 9px 16px; border-top: 1px solid var(--line); }
.source-meta, .export-format { display: flex; align-items: center; min-width: 0; gap: 7px; color: var(--muted); font-size: 12px; }
.source-meta .icon, .export-format .icon { width: 15px; height: 15px; color: var(--quiet); }
#filename { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-dims, .export-format { white-space: nowrap; font: 12px/1.2 var(--mono); }
.file-dims:not(:empty) { color: var(--quiet); border-left: 1px solid var(--line); padding-left: 7px; }
.export-format span { color: var(--quiet); font-size: 10px; }
.tool-footer > button { flex: 0 0 auto; }

.feedback {
  position: fixed;
  z-index: 3;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 11px 16px;
  background: #253731;
  border: 1px solid #53796a;
  border-radius: 5px;
  box-shadow: 0 6px 22px #070d0b70;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.feedback[data-tone="error"] { background: #3c2825; border-color: #8b6158; color: #ffd4c9; }
.site-footer {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  align-items: start;
  gap: 10px 20px;
  padding: 14px 0 20px;
  margin-top: 18px;
  border-top: 1px solid #2b3331;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}
.footer-heading { display: flex; flex-direction: column; align-items: flex-start; gap: 3px 16px; }
.footer-heading strong { color: var(--text); }
.footer-heading a { color: var(--accent); text-underline-offset: 3px; }
.footer-heading a:hover { color: var(--strong); }
.footer-copy { display: grid; gap: 3px; }
.footer-copy p { margin: 0; }

@media (max-width: 920px) {
  .shell { width: calc(100% - 48px); }
  .file-dims { display: none; }
}
@media (max-width: 720px) {
  .shell { width: calc(100% - 28px); }
  .masthead-inner { min-height: 60px; }
  .site-footer { grid-template-columns: minmax(0, 1fr); }
  .footer-heading { flex-direction: row; flex-wrap: wrap; align-items: baseline; }
  .page-title { padding-top: 23px; margin-bottom: 17px; }
  h1 { font-size: 34px; }
  .steps { column-gap: 11px; }
  .steps li { gap: 5px; }
  .steps .icon { margin-left: 1px; }
  .workbench { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .stage { height: clamp(259px, 42vh, 348px); }
  .tool-heading, .tool-footer, .tool-controls, .style-controls, .tone-controls { padding-inline: 12px; }
  .tool-button, .button { min-height: 42px; }
  .style-label { height: 42px; }
  .file-dims { display: inline; }
}
@media (max-width: 360px) {
  .file-dims { display: none; }
  .steps { gap: 7px; }
  .steps li { font-size: 12px; }
  .steps .icon { width: 10px; }
  .step-number { min-width: 23px; }
  .zoom-tools, .tool-controls { gap: 6px; }
  .style-label { gap: 4px; padding-inline: 6px; }
  .style-symbol { width: 19px; height: 19px; }
}
