:root {
  color-scheme: light;
  --page: #f1f1f2;
  --panel: #ffffff;
  --ink: #141416;
  --muted: #6c6c72;
  --line: #e3e3e6;
  --accent: #141416;
  --accent-strong: #000000;
  --accent-soft: #ececee;
  --shadow: 0 24px 48px -20px rgba(0, 0, 0, 0.22);
  --shadow-sm: 0 10px 24px -12px rgba(0, 0, 0, 0.2);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  position: relative;
  overflow-x: hidden;
}

.bg-blob {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
  pointer-events: none;
}

.bg-blob-a {
  top: -180px;
  left: -160px;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle at 30% 30%, #ffffff, transparent 70%);
}

.bg-blob-b {
  top: 20%;
  right: -220px;
  width: 460px;
  height: 460px;
  background: radial-gradient(circle at 70% 40%, #b9b9be, transparent 70%);
}

.bg-blob-c {
  bottom: -220px;
  left: 30%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle at 50% 50%, #141416, transparent 70%);
  opacity: 0.12;
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #000000 0%, #ffffff 100%);
  box-shadow: var(--shadow-sm);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.95) 0 6px, transparent 7px),
    radial-gradient(circle at 65% 65%, rgba(0, 0, 0, 0.55) 0 6px, transparent 7px);
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 14px;
  background: var(--panel);
  color: var(--accent-strong);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease, color 150ms ease;
  font-size: 1.1rem;
}

.icon-button:hover {
  transform: translateY(-1px);
  color: var(--accent-strong);
  box-shadow: 0 14px 28px -12px rgba(0, 0, 0, 0.3);
}

.mini-button:hover,
.download-button:hover {
  transform: translateY(-1px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.preview-panel,
.controls {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.preview-panel {
  overflow: hidden;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 66vh;
  background:
    linear-gradient(45deg, #ececee 25%, transparent 25%),
    linear-gradient(-45deg, #ececee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ececee 75%),
    linear-gradient(-45deg, transparent 75%, #ececee 75%);
  background-color: #fafafb;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  outline: 0;
  overflow: hidden;
}

.drop-zone.is-dragging {
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.3);
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone.has-image input {
  pointer-events: none;
}

.drop-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 4px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
}

.drop-icon svg {
  width: 30px;
  height: 30px;
}

.drop-copy strong {
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 600;
}

canvas {
  display: none;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 74vh;
  pointer-events: none;
  transform-origin: center center;
  transition: transform 120ms ease;
  border-radius: 12px;
}

.canvas-viewport {
  display: none;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: inherit;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.canvas-viewport.is-panning {
  cursor: grabbing;
}

.has-image canvas {
  display: block;
}

.has-image .canvas-viewport {
  display: grid;
}

.has-image .drop-copy {
  display: none;
}

.preview-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}

.preview-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.range-heading,
.control-title,
.checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

output {
  color: var(--accent-strong);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
}

.mini-button {
  min-height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: background 150ms ease, transform 150ms ease;
}

.mini-button:hover {
  background: #dcdcdf;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  accent-color: var(--accent);
}

.checkbox-row {
  justify-content: flex-start;
  color: var(--ink);
  font-size: 0.92rem;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.download-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.download-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #3a3a3f 0%, #000000 100%);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.download-button:hover:not(:disabled) {
  filter: brightness(1.15);
  box-shadow: 0 16px 30px -12px rgba(0, 0, 0, 0.4);
}

.download-button.secondary {
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.download-button.secondary:hover:not(:disabled) {
  background: #dcdcdf;
  filter: none;
}

.download-button:disabled {
  background: #e7e7ea;
  color: #adadb3;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

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

  .drop-zone {
    min-height: 54vh;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    margin: 18px auto;
  }

  .app-header {
    align-items: flex-start;
  }

  .drop-zone {
    min-height: 48vh;
  }

  .preview-meta,
  .checkbox-row {
    flex-direction: column;
    align-items: stretch;
  }
}

.site-footer {
  display: flex;
  justify-content: center;
  padding: 28px 0 8px;
}

.site-footer img {
  height: 30px;
  width: auto;
  opacity: 0.75;
  transition: opacity 150ms ease;
}

.site-footer a:hover img {
  opacity: 1;
}
