@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800;900&display=swap");

:root {
  --bg: #ffffff;
  --card: #ffffff;
  --line: rgba(14, 15, 12, 0.12);
  --text: #0e0f0c;
  --muted: #868685;
  --accent: #9fe870;
  --accent-dark: #163300;
  --accent-hover: #cdffad;
  --surface: #f8faf7;
  --shadow-ring: rgba(14, 15, 12, 0.12) 0px 0px 0px 1px;
}

* {
  box-sizing: border-box;
  font-feature-settings: "calt";
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(14, 15, 12, 0.08), var(--shadow-ring);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  transform: translateY(0);
  opacity: 1;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-hiding {
  opacity: 0;
  transform: translateY(-8px);
}

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(14, 15, 12, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.drag-overlay.is-visible {
  opacity: 1;
}

.drag-overlay-card {
  min-width: min(420px, calc(100vw - 48px));
  padding: 28px 32px;
  border: 2px dashed rgba(22, 51, 0, 0.34);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 60px rgba(14, 15, 12, 0.14);
  text-align: center;
}

.drag-overlay-card strong,
.drag-overlay-card span {
  display: block;
}

.drag-overlay-card strong {
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 900;
  line-height: 1.05;
}

.drag-overlay-card span {
  margin-top: 8px;
  font-size: 15px;
  color: var(--muted);
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 900;
  line-height: 0.98;
}

.hero-text {
  max-width: 620px;
  margin: 10px 0 0;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--muted);
}

.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--shadow-ring);
}

.panel {
  padding: 20px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(180px, 220px) minmax(320px, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.upload-box,
.brush-box {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}

.upload-box {
  text-align: center;
}

.upload-box.dragging {
  border-color: var(--accent-dark);
  background: #eef9e6;
  box-shadow: 0 0 0 4px rgba(159, 232, 112, 0.28);
  transform: translateY(-2px);
}

.hidden-input {
  display: none;
}

.file-name {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  word-break: break-word;
}

.upload-tip {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.brush-box label {
  font-size: 14px;
  font-weight: 600;
}

.brush-box input[type="range"] {
  width: 100%;
  accent-color: var(--accent-dark);
}

.action-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.action-row .ghost-button,
.action-row .secondary-button {
  white-space: nowrap;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 9999px;
  border: 0;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.primary-button {
  color: var(--accent-dark);
  background: var(--accent);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled) {
  transform: scale(1.05);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.secondary-button {
  color: var(--text);
  background: rgba(22, 51, 0, 0.08);
  border: 1px solid var(--line);
}

.ghost-button {
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none !important;
}

.hint {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--muted);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  padding: 18px;
}

.card-head {
  margin-bottom: 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.canvas-wrap {
  position: relative;
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(14, 15, 12, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(14, 15, 12, 0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(14, 15, 12, 0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(14, 15, 12, 0.04) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: var(--surface);
}

canvas {
  max-width: 100%;
  max-height: 78vh;
  display: none;
  border-radius: 16px;
}

#maskCanvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 16px;
  cursor: crosshair;
  touch-action: none;
}

.empty-state {
  padding: 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

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

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

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row button {
    width: 100%;
  }

  .canvas-wrap {
    min-height: 280px;
  }
}
