:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #1e3a8a;
  --border: #e5e7eb;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html {
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-y: auto;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.tool-page {
  display: grid;
  gap: 18px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.section-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}

.section-sub {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fbfbfd;
}

.input:disabled {
  color: #9ca3af;
  background: #f3f4f6;
  cursor: not-allowed;
}

.row {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.row.two-cols {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 150ms ease, opacity 150ms ease;
}

.btn.secondary {
  background: #e5e7eb;
  color: #1f2937;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.top-gap {
  margin-top: 8px;
}

.msg {
  min-height: 18px;
  margin-top: 8px;
  font-size: 13px;
  color: #b45309;
}

.result-meta,
.size-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 176px;
  padding: 20px;
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  background: #f8fafc;
  color: #334155;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.drop-zone:hover,
.drop-zone.is-drag-over {
  border-color: var(--accent);
  background: #eef2ff;
}

.drop-zone-title {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.drop-zone-sub {
  display: block;
  max-width: 320px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.preview-shell {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: clamp(220px, 34vh, 420px);
  max-height: min(62vh, 680px);
  overflow: auto;
  border-radius: 14px;
  padding: 18px;
  background-color: #f8fafc;
  background-image:
    linear-gradient(45deg, rgba(148, 163, 184, 0.14) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.14) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.14) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.14) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.preview-stage.is-empty {
  min-height: 240px;
  max-height: none;
}

.empty-preview {
  display: grid;
  place-items: center;
  width: min(100%, 440px);
  min-height: 160px;
  border: 2px dashed rgba(148, 163, 184, 0.45);
  border-radius: 16px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.empty-preview[hidden],
.preview-canvas[hidden] {
  display: none;
}

.preview-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

@media (max-width: 960px) {
  .preview-stage {
    padding: 14px;
  }
}

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

  .drop-zone {
    min-height: 150px;
  }

  .preview-shell {
    padding: 10px;
  }

  .preview-stage {
    min-height: 220px;
    padding: 10px;
  }

  .preview-stage.is-empty {
    min-height: 200px;
  }
}
