:root {
  color-scheme: light;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f8f1;
  color: #151616;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, rgba(199, 255, 91, 0.18), transparent 28%),
    linear-gradient(180deg, #fbfbf5 0%, #f4f6ee 100%);
  -webkit-text-size-adjust: 100%;
}

button,
input,
textarea {
  font: inherit;
}

.app {
  min-height: 100vh;
  padding: 22px;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1680px;
  margin: 0 auto 34px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #171817;
  font-size: 19px;
  font-weight: 800;
}

.brandMark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #c9ff3f;
  color: #151616;
  font-size: 15px;
  letter-spacing: 0;
}

.navBadge {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(21, 22, 22, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: #55594f;
  font-size: 14px;
}

.hero {
  max-width: 1680px;
  margin: 0 auto 22px;
}

.hero > div {
  max-width: none;
}

.eyebrow {
  margin: 0 0 12px;
  color: #557000;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: none;
  font-size: clamp(42px, 4.1vw, 70px);
  line-height: 1.03;
  letter-spacing: 0;
  color: #151616;
  white-space: nowrap;
}

.heroCopy {
  max-width: none;
  margin-top: 18px;
  color: #696d62;
  font-size: 18px;
  line-height: 1.65;
  white-space: nowrap;
}

h2 {
  color: #151616;
  font-size: 18px;
  line-height: 1.25;
}

p {
  color: #6c7065;
  line-height: 1.55;
}

.workspace {
  max-width: 1680px;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid rgba(21, 22, 22, 0.08);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 22px 70px rgba(34, 43, 24, 0.08);
  backdrop-filter: blur(18px);
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 360px;
  gap: 14px;
}

.previewPanel,
.controls {
  min-width: 0;
  border: 1px solid rgba(21, 22, 22, 0.08);
  border-radius: 22px;
  background: #ffffff;
}

.previewPanel {
  padding: 14px;
}

.panelHeader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.panelHeader p {
  margin-top: 4px;
  font-size: 13px;
}

.fileBtn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  border: 1px solid rgba(21, 22, 22, 0.12);
  border-radius: 999px;
  background: #ffffff;
  color: #151616;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 750;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease,
    background-color 140ms ease;
}

.fileBtn:hover,
button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(21, 22, 22, 0.22);
  box-shadow: 0 10px 24px rgba(24, 27, 18, 0.08);
}

.fileBtn input {
  display: none;
}

.primary {
  width: 100%;
  height: 50px;
  background: #151616;
  border-color: #151616;
  color: #ffffff;
  box-shadow: 0 16px 30px rgba(21, 22, 22, 0.16);
}

.downloadBtn {
  display: none;
  height: 42px;
  background: #c9ff3f;
  border-color: #c9ff3f;
  color: #151616;
  box-shadow: 0 12px 24px rgba(137, 191, 0, 0.2);
}

.downloadBtn.isReady {
  display: inline-flex;
}

.primary:disabled,
.downloadBtn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

.mediaBox {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 560px;
  overflow: hidden;
  border: 1px dashed rgba(21, 22, 22, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(45deg, rgba(21, 22, 22, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(21, 22, 22, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(21, 22, 22, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(21, 22, 22, 0.035) 75%);
  background-color: #fafbf7;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease;
}

.mediaBox.dragging {
  border-color: #a8e800;
  background-color: #fbfff0;
  box-shadow: inset 0 0 0 1px rgba(201, 255, 63, 0.55);
}

canvas {
  position: absolute;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  object-fit: contain;
}

#resultImage {
  display: none;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  border-radius: 14px;
  object-fit: contain;
  box-shadow: 0 18px 50px rgba(31, 36, 24, 0.12);
}

.emptyState {
  display: grid;
  gap: 8px;
  text-align: center;
  color: #777b70;
  padding: 24px;
}

.emptyState strong {
  color: #151616;
  font-size: 18px;
}

.fileName {
  margin-top: 11px;
  min-height: 22px;
  color: #666a60;
  font-size: 14px;
  overflow-wrap: anywhere;
}

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

.field {
  display: grid;
  gap: 10px;
}

.field span {
  color: #33352f;
  font-size: 14px;
  font-weight: 750;
}

textarea {
  width: 100%;
  min-height: 270px;
  resize: vertical;
  border: 1px solid rgba(21, 22, 22, 0.13);
  border-radius: 18px;
  background: #fbfcf8;
  padding: 15px;
  color: #151616;
  font-size: 16px;
  line-height: 1.65;
}

textarea::placeholder {
  color: #8a8f83;
}

textarea:focus,
button:focus-visible,
.fileBtn:focus-within {
  outline: 4px solid rgba(201, 255, 63, 0.42);
  outline-offset: 2px;
}

.status {
  min-height: 24px;
  color: #6c7065;
  font-size: 14px;
}

@media (max-width: 1260px) {
  h1 {
    font-size: clamp(34px, 5vw, 54px);
  }

  .heroCopy {
    font-size: 17px;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

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

  textarea {
    min-height: 150px;
  }
}

@media (max-width: 900px) {
  .app {
    padding: 14px;
  }

  .nav {
    margin-bottom: 24px;
  }

  h1 {
    font-size: 36px;
    white-space: normal;
  }

  .heroCopy {
    font-size: 16px;
    white-space: normal;
  }

  .workspace {
    border-radius: 24px;
    padding: 10px;
  }

  .stage {
    display: block;
  }

  .previewPanel,
  .controls {
    margin-bottom: 10px;
  }

  .controls {
    margin-bottom: 0;
  }

  .mediaBox {
    min-height: min(430px, 58vh);
  }
}

@media (max-width: 640px) {
  .app {
    padding: 12px;
  }

  .navBadge {
    display: none;
  }

  .hero {
    margin-bottom: 18px;
  }

  h1 {
    font-size: 31px;
    line-height: 1.12;
  }

  h2 {
    font-size: 17px;
  }

  .heroCopy {
    margin-top: 14px;
  }

  .workspace {
    padding: 8px;
    border-radius: 22px;
  }

  .previewPanel,
  .controls {
    border-radius: 18px;
    padding: 12px;
  }

  .panelHeader {
    align-items: flex-start;
  }

  .fileBtn,
  button {
    min-height: 44px;
    height: 44px;
    padding: 0 15px;
  }

  .mediaBox {
    min-height: min(350px, 46vh);
    border-radius: 16px;
  }

  .emptyState {
    padding: 18px;
  }

  .emptyState strong {
    font-size: 16px;
  }

  .fileName {
    font-size: 13px;
  }

  textarea {
    min-height: 168px;
    padding: 13px;
  }

  .primary {
    position: sticky;
    bottom: 10px;
    z-index: 2;
  }

  .status {
    font-size: 13px;
  }
}

@media (max-width: 390px) {
  .app {
    padding: 8px;
  }

  .brand {
    font-size: 17px;
  }

  h1 {
    font-size: 28px;
  }

  .panelHeader {
    gap: 10px;
  }

  .fileBtn,
  button {
    padding: 0 12px;
  }

  .mediaBox {
    min-height: min(310px, 42vh);
  }
}
