:root {
  color-scheme: light;
  --bg: #eff3f9;
  --panel-bg: #ffffff;
  --line: #d7dfeb;
  --text: #1e293b;
  --muted: #60708a;
  --primary: #0078d4;
  --primary-hover: #0060ae;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(0, 120, 212, 0.12), transparent 34%),
    radial-gradient(circle at 0% 80%, rgba(11, 140, 112, 0.08), transparent 28%),
    var(--bg);
}

.hero {
  background: linear-gradient(135deg, #072b4f 0%, #0f5ea8 52%, #13a89e 100%);
  color: #fff;
  padding: 56px 18px;
}

.hero-content {
  max-width: 1080px;
  margin: 0 auto;
}

.badge {
  display: inline-flex;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.23);
}

h1 {
  margin: 10px 0 10px;
  font-size: clamp(34px, 4vw, 48px);
}

.hero p {
  margin: 0;
  max-width: 760px;
  line-height: 1.6;
}

.container {
  max-width: 1080px;
  margin: 24px auto 58px;
  padding: 0 14px;
}

.tool {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 28px rgba(10, 48, 94, 0.07);
}

.tool h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.tip {
  margin: 0 0 16px;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid #dce5f2;
  border-radius: 10px;
  background: #fbfdff;
  font-size: 13px;
}

.field span {
  color: #3b4d68;
}

.file-field input[type="file"] {
  width: 100%;
}

input,
select,
button {
  font-size: 14px;
  border-radius: 8px;
}

input,
select {
  border: 1px solid #c6d2e3;
  padding: 8px;
  background: #fff;
}

input[type="number"] {
  width: 100%;
}

.quality-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
}

.quality-field span {
  grid-column: 1 / 3;
}

.quality-field strong {
  min-width: 32px;
  text-align: right;
}

button {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

button:hover:enabled {
  background: var(--primary-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-button {
  background: #0f766e;
}

.secondary-button:hover:enabled {
  background: #0c5f59;
}

.workspace {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 14px;
}

.panel {
  border: 1px solid #d8e2ef;
  border-radius: 12px;
  background: #f9fbff;
  padding: 12px;
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #30445f;
}

.canvas-wrap {
  width: 100%;
  min-height: 260px;
  border: 1px dashed #c7d5e8;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  background:
    linear-gradient(45deg, #e8edf7 25%, transparent 25%, transparent 75%, #e8edf7 75%, #e8edf7),
    linear-gradient(45deg, #e8edf7 25%, transparent 25%, transparent 75%, #e8edf7 75%, #e8edf7);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
}

#sourceCanvas {
  display: block;
  max-width: 100%;
  max-height: 520px;
  touch-action: none;
  cursor: grab;
}

#sourceCanvas.dragging {
  cursor: grabbing;
}

.preview-wrap {
  min-height: 220px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px dashed #c7d5e8;
  border-radius: 10px;
  background:
    linear-gradient(45deg, #e8edf7 25%, transparent 25%, transparent 75%, #e8edf7 75%, #e8edf7),
    linear-gradient(45deg, #e8edf7 25%, transparent 25%, transparent 75%, #e8edf7 75%, #e8edf7);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
}

#cropPreviewCanvas {
  display: block;
  max-width: 100%;
  border-radius: 8px;
}

.crop-metrics {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #d4deec;
  border-radius: 9px;
  background: #fff;
  font-size: 13px;
  color: #2c405b;
}

.info-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.info-item {
  border: 1px solid #d9e2ef;
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
}

.info-item span {
  display: block;
  font-size: 12px;
  color: #5c708f;
  margin-bottom: 3px;
}

.info-item strong {
  font-size: 14px;
  color: #1f3048;
}

.download-row {
  margin-top: 14px;
}

.download-row a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #0d2f55;
  border: 1px solid #b8cae3;
  border-radius: 8px;
  padding: 8px 12px;
  text-decoration: none;
  background: #fff;
}

.footer {
  text-align: center;
  margin: 22px 0 28px;
  color: #5f7190;
  font-size: 13px;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 44px 16px;
  }

  .tool {
    padding: 16px;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .controls > button {
    grid-column: 1 / -1;
  }
}

.footer-sep {
  color: #94a3b8;
}

.beian-link {
  color: #475569;
  text-decoration: none;
}

.beian-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

@media (max-width: 680px) {
  .tool {
    padding: 14px;
  }

  h1 {
    font-size: 36px;
  }
}
