:root {
  --ink: #17211d;
  --muted: #5e6b66;
  --paper: #f3f2ec;
  --panel: #fffdfa;
  --line: #d7d0c7;
  --accent: #0f766e;
  --accent-dark: #134e4a;
  --accent-soft: rgba(15, 118, 110, 0.14);
  --shadow: 0 24px 60px rgba(23, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.78), transparent 32%),
    linear-gradient(180deg, #ece8df 0%, var(--paper) 42%, #f8f7f3 100%);
}

button,
input,
select {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

input:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.tool-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 24px);
}

.tool-chrome {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.admin-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid rgba(19, 78, 74, 0.16);
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 20px rgba(23, 33, 29, 0.06);
}

.admin-shortcut:hover {
  border-color: rgba(19, 78, 74, 0.28);
  background: rgba(240, 247, 246, 0.92);
}

.config-shell {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  padding: clamp(16px, 2.4vw, 26px);
  background: linear-gradient(180deg, rgba(255, 253, 250, 0.96), rgba(255, 252, 246, 0.92));
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.config-hero {
  max-width: 56rem;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3.6vw, 3.4rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.intro {
  max-width: 56rem;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.config-warning {
  margin-bottom: 14px;
  border: 1px solid #f1b98a;
  border-radius: 18px;
  padding: 14px 16px;
  color: #8f3a10;
  background: #fff3eb;
}

.config-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(18px, 3vw, 28px);
  align-items: start;
}

.form-column {
  display: grid;
  gap: 12px;
}

.field-block,
legend {
  color: var(--accent-dark);
  font-weight: 700;
}

.config-topbar,
.text-field {
  display: grid;
  gap: 8px;
}

.config-topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.option-group {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 8px;
}

.option-group legend {
  padding: 0;
}

.font-card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.font-card {
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 6px;
  min-height: 88px;
  padding: 12px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.font-card:hover {
  transform: translateY(-2px);
  border-color: rgba(19, 78, 74, 0.3);
  box-shadow: 0 12px 26px rgba(23, 33, 29, 0.08);
}

.font-card input,
.swatch-option input,
.size-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.font-card:has(input:checked),
.swatch-option:has(input:checked),
.size-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent-soft);
  background: rgba(240, 247, 246, 0.95);
}

.font-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}

.font-card-code {
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.font-card-name {
  font-size: 0.94rem;
  font-weight: 700;
}

.font-card-preview {
  display: flex;
  align-items: flex-start;
  min-height: 0;
  overflow: visible;
  padding: 0;
  color: #2f2922;
}

.font-card-preview-text {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: clamp(1.15rem, 1.6vw, 1.58rem);
  line-height: 1.28;
  padding-block: 0.14em 0.18em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 花体字的上探笔画超出常规 ascender，需要额外安全边距避免预览误裁切。 */
.font-card[data-font-name="Babylone"] .font-card-preview-text {
  font-size: clamp(1.06rem, 1.48vw, 1.42rem);
  line-height: 1.34;
  padding-block: 0.26em 0.18em;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
}

.swatch-option,
.size-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.76);
  cursor: pointer;
}

.size-option {
  justify-content: center;
  min-height: 46px;
}

.swatch-option-compact {
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  text-align: center;
}

.swatch-chip {
  width: min(100%, 36px);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--swatch);
}

.swatch-text-compact {
  align-items: center;
  justify-items: center;
  gap: 1px;
  font-size: 0.72rem;
  line-height: 1.15;
}

.swatch-text-compact small {
  color: var(--muted);
  font-size: 0.68rem;
  white-space: normal;
}

.swatch-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  font-size: 0.92rem;
}

.swatch-text small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.size-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.inline-field span {
  color: var(--muted);
}

.radius-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.radius-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.radius-row {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) minmax(120px, 180px);
  gap: 12px;
  align-items: center;
}

.radius-readout {
  min-width: 4.5em;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
}

.radius-preview {
  display: flex;
  justify-content: center;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
}

.radius-preview-box {
  width: min(100%, 160px);
  height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(23, 33, 29, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(232, 225, 213, 0.92)),
    linear-gradient(135deg, rgba(23, 33, 29, 0.04), rgba(23, 33, 29, 0));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 6px 14px rgba(23, 33, 29, 0.08);
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.actions-inline {
  margin-top: 0;
}

button {
  border: 0;
  border-radius: 999px;
  min-height: 46px;
  padding: 12px 24px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: 0 16px 28px rgba(19, 78, 74, 0.22);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.progress-shell {
  display: grid;
  gap: 18px;
}

.progress-top-bar {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.progress-top-bar .progress-error {
  width: 100%;
}

.progress-summary,
.progress-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.progress-headline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.progress-track {
  margin-top: 12px;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(19, 78, 74, 0.12);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  transition: width 240ms ease;
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.progress-panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.stage-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.stage-copy {
  display: grid;
  gap: 4px;
}

.stage-copy span,
.stage-status,
.artifact-stage header span,
.artifact-meta span,
.empty-state,
.back-link {
  color: var(--muted);
}

.stage-status {
  font-size: 0.82rem;
  text-transform: uppercase;
}

.artifact-feed {
  display: grid;
  gap: 14px;
}

.artifact-stage {
  display: grid;
  gap: 10px;
}

.artifact-stage header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.artifact-stage-copy {
  display: grid;
  gap: 4px;
}

.artifact-stage-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.artifact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.artifact-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
}

.artifact-card-image {
  width: 100%;
  color: inherit;
  text-align: left;
  box-shadow: none;
  cursor: zoom-in;
}

.artifact-card.is-featured {
  border-color: rgba(15, 118, 110, 0.34);
  background: linear-gradient(180deg, rgba(240, 247, 246, 0.96), rgba(255, 255, 255, 0.92));
  box-shadow: 0 18px 32px rgba(15, 118, 110, 0.1);
}

.artifact-card img {
  width: 100%;
  display: block;
  height: auto;
  max-height: min(52vh, 560px);
  object-fit: contain;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.06), rgba(19, 78, 74, 0.12));
}

.artifact-card img.artifact-image-square {
  border-radius: 0;
}

.artifact-card-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.artifact-card-role,
.artifact-card-order {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.artifact-card-role {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
}

.artifact-card-order {
  letter-spacing: 0.08em;
}

.artifact-card-file {
  align-content: space-between;
}

.artifact-card a,
.back-link {
  text-decoration: none;
}

.artifact-meta {
  display: grid;
  gap: 4px;
}

.artifact-note {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
}

.artifact-card-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.progress-error {
  border: 1px solid #f1b98a;
  border-radius: 18px;
  padding: 14px 16px;
  color: #8f3a10;
  background: #fff3eb;
}

.back-link {
  justify-self: start;
}

.result-shell {
  display: grid;
  gap: 18px;
}

.result-top-bar {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.result-top-bar .progress-error {
  width: 100%;
}

.result-banner,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.result-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.result-status-copy {
  display: grid;
  gap: 6px;
}

.result-status-copy strong {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.primary-download-slot {
  display: flex;
  justify-content: flex-end;
}

.primary-download-button,
.download-item {
  text-decoration: none;
}

.primary-download-button {
  display: grid;
  gap: 4px;
  min-width: min(320px, 100%);
  padding: 16px 20px;
  border-radius: 24px;
  color: #ffffff;
  background: linear-gradient(135deg, #134e4a, #0f766e);
  box-shadow: 0 18px 30px rgba(19, 78, 74, 0.22);
}

.primary-download-button span {
  font-size: 1.1rem;
  font-weight: 700;
}

.primary-download-button small {
  color: rgba(255, 255, 255, 0.82);
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.result-sidebar {
  display: grid;
  gap: 18px;
}

.result-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.result-panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.result-gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.gallery-card {
  display: grid;
  gap: 10px;
  width: min(100%, 960px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: inherit;
  text-align: left;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: none;
  justify-self: start;
}

.gallery-card.is-featured {
  border-color: rgba(15, 118, 110, 0.34);
  background: linear-gradient(180deg, rgba(240, 247, 246, 0.96), rgba(255, 255, 255, 0.92));
  box-shadow: 0 18px 32px rgba(15, 118, 110, 0.1);
}

.gallery-card:hover {
  transform: translateY(-2px);
  border-color: rgba(19, 78, 74, 0.3);
  box-shadow: 0 14px 28px rgba(23, 33, 29, 0.08);
}

.gallery-card img {
  width: 100%;
  display: block;
  height: auto;
  max-height: min(56vh, 620px);
  object-fit: contain;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.05), rgba(19, 78, 74, 0.12));
}

.gallery-card img.gallery-image-square {
  border-radius: 0;
}

.gallery-card-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.gallery-card-role,
.gallery-card-order {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.gallery-card-role {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
}

.gallery-card-order {
  letter-spacing: 0.08em;
}

.gallery-card-label {
  font-size: 1.05rem;
  font-weight: 700;
}

.gallery-card-note {
  color: var(--ink);
  line-height: 1.6;
}

.gallery-card-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.download-list {
  display: grid;
  gap: 10px;
}

.download-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: inherit;
  background: rgba(255, 255, 255, 0.9);
}

.download-item.is-primary {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(240, 247, 246, 0.95);
}

.download-item span,
.warning-list {
  color: var(--muted);
}

.result-summary {
  display: grid;
  gap: 10px;
  margin: 0;
}

.summary-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
}

.summary-item dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-item dd {
  margin: 0;
  font-weight: 700;
}

.warning-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.result-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.image-viewer,
.result-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
}

.viewer-backdrop,
.result-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(17, 24, 39, 0.68);
}

.viewer-dialog,
.result-modal-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 16px;
  width: min(1100px, 100%);
  height: min(920px, calc(100vh - 40px));
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  background: rgba(255, 253, 250, 0.98);
  box-shadow: 0 28px 80px rgba(17, 24, 39, 0.28);
}

.viewer-head,
.result-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.viewer-head h2,
.result-modal-head h2 {
  margin: 0;
  font-size: 1rem;
}

.viewer-close,
.result-modal-close {
  padding: 10px 18px;
}

.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 18px;
  background: rgba(245, 250, 249, 0.9);
}

.viewer-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.viewer-zoom-button {
  min-width: 88px;
  padding: 10px 16px;
  box-shadow: none;
}

.viewer-zoom-button.is-active {
  background: linear-gradient(135deg, rgba(19, 78, 74, 0.94), rgba(15, 118, 110, 0.94));
}

.viewer-viewport {
  overflow: hidden;
  min-height: 0;
  padding: 18px;
  border: 1px solid rgba(15, 118, 110, 0.12);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(240, 247, 246, 0.92)),
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.08), transparent 28%);
}

.viewer-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
}

.viewer-media,
.result-modal-image {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: auto;
  max-width: none;
  max-height: none;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.05), rgba(19, 78, 74, 0.12));
  transform-origin: 50% 50%;
  will-change: transform;
}

.viewer-canvas.is-square-corner .viewer-media,
.result-modal-image.is-square-corner {
  border-radius: 0;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 1080px) {
  .config-form {
    grid-template-columns: 1fr;
  }

  .config-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .font-card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .swatch-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .size-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .radius-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .progress-layout {
    grid-template-columns: 1fr;
  }

  .result-banner,
  .result-layout {
    grid-template-columns: 1fr;
  }

  .primary-download-slot {
    justify-content: stretch;
  }

  .result-gallery {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .tool-chrome {
    margin-bottom: 10px;
  }

  .font-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .swatch-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .tool-shell {
    padding: 10px;
  }

  .tool-chrome {
    margin-bottom: 8px;
  }

  .config-shell {
    border-radius: 24px;
    padding: 16px;
  }

  .font-card-grid,
  .artifact-grid,
  .result-gallery {
    grid-template-columns: 1fr;
  }

  .swatch-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .size-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-card {
    width: 100%;
  }

  .actions {
    justify-content: stretch;
  }

  button,
  .primary-download-button {
    width: 100%;
  }

  .image-viewer,
  .result-modal {
    padding: 10px;
  }
}
