:root {
  --bg: #f6fbff;
  --card: #ffffff;
  --ink: #18324a;
  --muted: #5f768f;
  --line: #d6e6f3;
  --primary: #2ea85f;
  --primary-strong: #238a4d;
  --secondary: #2f80ed;
  --secondary-strong: #266ac6;
  --accent: #45c6b4;
  --radius: 16px;
  --shadow: 0 16px 44px rgba(24, 50, 74, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Nunito", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 10%, #e9f7ff 0%, var(--bg) 45%),
    linear-gradient(150deg, #fff8ef 0%, #f6fbff 70%);
  min-height: 100%;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(2px);
  z-index: -1;
  opacity: 0.55;
}

.bg-shape-a {
  width: 260px;
  height: 260px;
  background: #ffe4c4;
  top: -80px;
  right: 8%;
}

.bg-shape-b {
  width: 200px;
  height: 200px;
  background: #b5f0e8;
  bottom: -70px;
  left: 4%;
}

.topbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 18px 10px;
}

.brand {
  margin: 0;
  font-family: "Baloo 2", "Trebuchet MS", cursive;
  font-size: clamp(2rem, 5vw, 3rem);
  color: #11456d;
  letter-spacing: 0.4px;
}

.slogan {
  margin: 6px 0 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 18px 36px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(12, 1fr);
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.emoji-dot {
  display: inline-block;
  width: 1.35em;
  text-align: center;
  margin-right: 0.18em;
}

.muted {
  margin: 0 0 12px;
  color: var(--muted);
}

.uploader-panel,
.config-panel,
.download-panel {
  grid-column: span 12;
}

.preview-panel {
  grid-column: span 12;
}

.drop-zone {
  display: flex;
  min-height: 140px;
  border-radius: 14px;
  border: 2px dashed #8bc6f1;
  background: linear-gradient(160deg, #f8fdff, #ecf7ff);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.drop-zone:hover,
.drop-zone.drag-active {
  transform: translateY(-2px);
  border-color: #51a7e0;
  background: linear-gradient(160deg, #eff9ff, #def1ff);
}

.drop-main {
  font-size: 1.08rem;
  font-weight: 800;
}

.drop-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.image-meta {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #385a76;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.controls-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
}

select,
input[type="number"] {
  appearance: none;
  border: 1px solid #c5d9ea;
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 10px;
}

select:focus,
input[type="number"]:focus {
  border-color: #63afe0;
  outline: 2px solid rgba(99, 175, 224, 0.22);
}

.stats-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid #d4e7f7;
  border-radius: 12px;
  background: #f7fcff;
  padding: 10px;
}

.stat-card span {
  display: block;
  font-size: 0.9rem;
  color: #54708b;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  font-size: 1.1rem;
}

.preview-wrap {
  border: 1px solid #d9e9f8;
  border-radius: 12px;
  background: #f4f9fd;
  overflow: hidden;
}

#previewCanvas {
  width: 100%;
  height: auto;
  display: block;
  max-height: 70vh;
  background: #fff;
}

.btn-main {
  width: 100%;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #4cc978);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.4px;
  min-height: 52px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 14px 24px rgba(35, 138, 77, 0.26);
}

.btn-main:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--primary-strong), #39ad65);
}

.btn-main:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.action-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.action-row .btn-main {
  flex: 2;
}

.action-row .btn-secondary {
  flex: 1;
}

.btn-secondary {
  width: 100%;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--secondary), #59a0ff);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.25px;
  min-height: 52px;
  font-size: 0.94rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 12px 20px rgba(47, 128, 237, 0.24);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, var(--secondary-strong), #4689de);
  transform: translateY(-1px);
}

.btn-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.status {
  margin: 10px 0 0;
  color: #45647f;
  font-size: 0.93rem;
}

.footer {
  text-align: center;
  padding: 14px 12px 26px;
  color: #53708b;
  font-weight: 700;
  font-size: 0.92rem;
}

@media (min-width: 900px) {
  .uploader-panel,
  .config-panel {
    grid-column: span 6;
  }

  .preview-panel,
  .download-panel {
    grid-column: span 12;
  }
}

@media (max-width: 640px) {
  .controls-grid,
  .stats-row {
    grid-template-columns: 1fr;
  }

  .action-row {
    flex-direction: row;
    gap: 8px;
  }

  .action-row .btn-main,
  .action-row .btn-secondary {
    min-height: 48px;
    font-size: 0.86rem;
  }

  .panel {
    padding: 14px;
  }
}
